Crate nstd_net

Crate nstd_net 

Source

Functions§

nstd_net_free_bytes
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.
nstd_net_free_ip
Deallocates memory where an IP address string is allocated. Parameters: char **ip - The IP address.
nstd_net_tcp_server_accept
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.
nstd_net_tcp_server_accept_all
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.
nstd_net_tcp_server_bind
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.
nstd_net_tcp_server_close
Closes a TCP server and frees memory allocated by nstd_net_tcp_server_bind. Parameters: NSTDTCPServer *server - Pointer to the server.
nstd_net_tcp_stream_close
Closes and frees memory of a TCP stream. Parameters: NSTDTCPStream *stream - Pointer to the TCP stream.
nstd_net_tcp_stream_connect
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.
nstd_net_tcp_stream_read
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.
nstd_net_tcp_stream_write
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.
nstd_net_udp_socket_bind
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.
nstd_net_udp_socket_close
Closes and frees memory of a UDP socket. Parameters: NSTDUDPSocket *socket - Pointer to the UDP socket.
nstd_net_udp_socket_connect
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.
nstd_net_udp_socket_receive
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.
nstd_net_udp_socket_receive_from
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.
nstd_net_udp_socket_send
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.
nstd_net_udp_socket_send_to
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.

Type Aliases§

NSTDTCPServer
Represents a TCP server.
NSTDTCPStream
Represents a TCP stream.
NSTDUDPSocket
Represents a UDP socket.