Frees bytes allocated by any of the nstd_net_* functions.
parameters:
NSTDByte **bytes - Pointer to the bytes to free.
const NSTDUSize size - Number of bytes.
Accepts a connection on the TCP server. Call nstd_net_tcp_stream_close to free memory
allocated by this function and close the connection.
Parameters:
NSTDTCPServer server - The TCP server.
Returns: NSTDTCPStream client - The server<=>client stream.
Accepts all incoming connect requests, calling callback for each connection.
Parameters:
NSTDTCPServer server - The TCP server.
void(*callback)(NSTDTCPStream) - The callback function when a connection is made.
Creates a TCP server bound to the given address. Call nstd_net_tcp_server_close to free
memory allocated by this function and close the server.
Parameters:
const char *const addr - The address to listen on, formatted as “IP:Port”.
Returns: NSTDTCPServer server - The TCP server, null on error.
Connects a TCP stream to a server.
Parameters:
const char *const addr - The address to connect to.
Returns: NSTDTCPStream client - The TCP stream connected to the server.
Reads data from a TCP stream.
Parameters:
NSTDTCPStream stream - The TCP stream.
NSTDUSize *size - Returns as the number of bytes read.
Returns: NSTDByte *bytes - The bytes read from the stream.
Writes data to a TCP stream.
Parameters:
NSTDTCPStream stream - The TCP stream.
const NSTDByte *const bytes - The bytes to write.
const NSTDUSize size - Number of bytes to write.
Returns: int errc - Nonzero on error.
Creates a UDP socket bound to the given address. Call nstd_net_udp_socket_close to free
memory allocated by this function and close the socket.
Parameters:
const char *const addr - The address to listen on, formatted as “IP:Port”.
Returns: NSTDUDPSocket socket - The UDP socket, null on error.
Connects a UDP socket to a remote address.
Parameters:
NSTDUDPSocket socket - The socket to connect.
const char *const addr - The remote address to connect to.
Returns: int errc - Nonzero on error.
Receives bytes sent from the connected address.
Parameters:
NSTDUDPSocket socket - The socket to receive bytes on.
const NSTDUSize num - Number of bytes to receive.
NSTDUSize *size - Returns as actual number of bytes received.
Returns: NSTDByte *bytes - The bytes received.
Receives bytes sent to a UDP socket.
Parameters:
NSTDUDPSocket socket - The socket to receive bytes from.
const NSTDUSize num - Number of bytes to receive.
NSTDUSize *size - Returns as actual number of bytes received.
char **ip - Returns as the socket IP address the bytes came from.
Returns: NSTDByte *bytes - The bytes received.
Sends bytes from a UDP socket to another.
Parameters:
NSTDUDPSocket socket - The UDP socket.
const NSTDByte *const bytes - The bytes to send.
const NSTDUSize num - Number of bytes to send.
NSTDUSize *size - Returns as number of bytes actually sent.
Returns: int errc - Nonzero on error.
Sends bytes from a UDP socket to another.
Parameters:
NSTDUDPSocket socket - The UDP socket.
const char *const addr - The address to send the bytes to.
const NSTDByte *const bytes - The bytes to send.
const NSTDUSize num - Number of bytes to send.
NSTDUSize *size - Returns as number of bytes actually sent.
Returns: int errc - Nonzero on error.