Changes

Jump to navigation Jump to search
933 bytes added ,  00:13, 6 November 2019
[[Sockets_services|Socket]] setup (standard names are used here, instead of the actual Nintendo func/param names):
* Sets the output sockfds in state to -1 (unrelated to "sockfd" below).* Clears the sockaddr_in.* sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); {handle error on fail}* Uses fcntl with F_GETFL/F_SETFL to set O_NONBLOCK, handling error on fail.* u64 tmpval=1; setsockopt(sockfd, SOL_SOCKET, SO_VENDOR + 0x1, &tmpval, sizeof(tmpval)); {handle error on fail}* u32 tmpval2=1; setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &tmpval2, sizeof(tmpval2)); {handle error on fail}* Initializes sockaddr_in: sin_addr = htonl({input ipaddr}), sin_port = htons({input port}), and sin_family = AF_INET (sin_len is left at 0).* bind(sockfd, sockaddr_in, sizeof(sockaddr_in)); {handle error on fail}* listen(sockfd, 1); {handle error on fail}* Writes sockfd to the output sockfd state field, copies the input ipaddr u32 into state, then returns 0.* The error handling for bind()/listen() will also close the socket, when certain errors occur.
== Cmd77 ==

Navigation menu