1,293 bytes added ,  23:17, 5 November 2019
no edit summary
This does state setup, copies ContentMetaKey/firmware_variation/unk into state + more setup, and does socket setup.
[[Sockets_services|Socket]] setup (standard names are used here, instead of the actual Nintendo func/param names):
* Sets the output sockfd in state to -1 (unrelated to "sockfd" below).
* Clears the sockaddr_in.
* sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); {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).
* Uses fcntl with F_GETFL/F_SETFL to set O_NONBLOCK, handling error on fail.
* connect(sockfd, sockaddr_in, sizeof(sockaddr_in));
** On failure:
** When the error is EINPROGRESS:
*** Uses select() with input setup for {content of writefds = sockfd}, and timeval setup for a 5-second timeout.
*** When the ret is 0, returns an error since a timeout occured. When the ret is not negative, proceeds to the below setsockopt handling. When negative, run the below error handling.
** Does error handling and returns.
* u64 tmpval=1; setsockopt(sockfd, SOL_SOCKET, SO_VENDOR + 0x1, &tmpval, sizeof(tmpval)); {handle error on fail}
* Uses fcntl with F_GETFL/F_SETFL to clear O_NONBLOCK, handling error on fail.
* Writes sockfd to the output sockfd state field, then returns 0.
* All error handling following successful sockfd creation via socket() will also close the socket, when certain errors occur.
== Cmd71 ==
This does state setup, does the above ContentMetaType validation, copies ContentMetaKey/firmware_variation into state, and does socket setup.
Socket setup (standard names are used here, instead of the actual Nintendo func/param names):
* ...
== Cmd77 ==
Content can be transferred with a custom protocol over the network. This is intended for use with local [[LDN_services|ldn]] networks, however the used IP addresses can be arbitary. This can be used for SystemUpdates via the above Send/Receive commands (which are then used via [[NS_Services#ns:su|ns:su]]). Application content can also be transferred, which uses a similar (?) protocol.
Task See [[#Cmd69|creation]] for Receive will eventually use the input addr/port with [[Sockets_services|connect()]], while the Send [[#Cmd76|version]] will eventually do for the same with [[Sockets_services|bind()]]socket setup during Receive/Send task creation. Hence, Receive system = client, while Send system = server.
The Receive async [[#Cmd72|thread]] does the following: