All rights reserved.
Simple Socket is a library to simplify the handling of sockets.
All functions with a container (unless declared with const) will write data to the container parameter related to the other parameters in the same function call.
The following naming convention for the functions are used:
Data Structures | |
struct | socketContainer_t |
Defines | |
#define | IP_ERROR_NO_PROTO -2 |
#define | IP_ERROR_NULL_PROTO -3 |
#define | IP_ERROR_UNKNOWN_ADDRESS 0xffffffff |
Functions | |
int | ipv4_proto_s (char *proto) |
int | ipv4_dgram_socket_s (char *proto) |
int | ipv4_stream_socket_s (char *proto) |
short | ipv4_service_ss (char *proto, char *service) |
short | ipv4_service_h (short service) |
long int | ipv4_address_s (const char *address) |
int | ipv4_udp_bind_ss (struct socketContainer_t *container, char *service, char *address) |
int | ipv4_udp_bind_hs (struct socketContainer_t *container, short service, char *address) |
int | ipv4_udp_bind_ns (struct socketContainer_t *container, short service, char *address) |
int | ipv4_tcp_bind_ss (struct socketContainer_t *container, char *service, char *address) |
int | ipv4_tcp_bind_hs (struct socketContainer_t *container, short service, char *address) |
int | ipv4_tcp_bind_ns (struct socketContainer_t *container, short service, char *address) |
int | ipv4_tcp_listen_ss (struct socketContainer_t *container, char *service, char *address, int max) |
int | ipv4_tcp_listen_hs (struct socketContainer_t *container, short service, char *address, int max) |
int | ipv4_tcp_listen_ns (struct socketContainer_t *container, short service, char *address, int max) |
int | ipv4_tcp_connect_ss (struct socketContainer_t *container, char *service, char *address) |
int | ipv4_tcp_connect_hs (struct socketContainer_t *container, short service, char *address) |
int | ipv4_tcp_connect_ns (struct socketContainer_t *container, short service, char *address) |
int | ipv4_tcp_accept (const struct socketContainer_t *listen_cont, struct socketContainer_t *client_cont) |
#define IP_ERROR_NO_PROTO -2 |
#define IP_ERROR_NULL_PROTO -3 |
#define IP_ERROR_UNKNOWN_ADDRESS 0xffffffff |
long int ipv4_address_s | ( | const char * | address | ) |
Get an IP number
address | Host name or IP address as string |
int ipv4_dgram_socket_s | ( | char * | proto | ) |
Create a datagram socket.
proto | Protocol string |
int ipv4_proto_s | ( | char * | proto | ) |
Get IPv4 protocol number from name.
proto | Protocol string |
short ipv4_service_h | ( | short | service | ) |
Get a service port number
service | Service number in host byte order. |
short ipv4_service_ss | ( | char * | proto, | |
char * | service | |||
) |
Get a service port number
proto | Protocol string | |
service | Service name or number as string |
int ipv4_stream_socket_s | ( | char * | proto | ) |
Create a stream socket.
proto | Protocol string |
int ipv4_tcp_accept | ( | const struct socketContainer_t * | listen_cont, | |
struct socketContainer_t * | client_cont | |||
) |
Accept connection for a TCP port. The new socket is set in client_cont, so make sure to close appropriately.
listen_cont | Socket container with socket to listen to. | |
client_cont | Socket container with information of client. Make sure that this parameter is initialized to zero, or specified to a specific client that is allowed. |
int ipv4_tcp_bind_hs | ( | struct socketContainer_t * | container, | |
short | service, | |||
char * | address | |||
) |
Bind to a TCP port A new socket is always created, so make sure that is closed appropriately.
container | Socket container. | |
service | Service number in host byte order. | |
address | Name or IP address as string (NULL gives 0.0.0.0). |
int ipv4_tcp_bind_ns | ( | struct socketContainer_t * | container, | |
short | service, | |||
char * | address | |||
) |
Bind to a TCP port A new socket is always created, so make sure that is closed appropriately.
container | Socket container. | |
service | Service number in network byte order. | |
address | Name or IP address as string (NULL gives 0.0.0.0). |
int ipv4_tcp_bind_ss | ( | struct socketContainer_t * | container, | |
char * | service, | |||
char * | address | |||
) |
Bind to a TCP port A new socket is always created, so make sure that is closed appropriately.
container | Socket container. | |
service | Service name or number as string. | |
address | Name or IP address as string (NULL gives 0.0.0.0). |
int ipv4_tcp_connect_hs | ( | struct socketContainer_t * | container, | |
short | service, | |||
char * | address | |||
) |
Connect to a TCP port A new socket is always created, so make sure that is closed appropriately.
container | Socket container. | |
service | Service number in host byte order. | |
address | Name or IP address as string. |
int ipv4_tcp_connect_ns | ( | struct socketContainer_t * | container, | |
short | service, | |||
char * | address | |||
) |
Connect to a TCP port A new socket is always created, so make sure that is closed appropriately.
container | Socket container. | |
service | Service number in network byte order. | |
address | Name or IP address as string. |
int ipv4_tcp_connect_ss | ( | struct socketContainer_t * | container, | |
char * | service, | |||
char * | address | |||
) |
Connect to a TCP port A new socket is always created, so make sure that is closed appropriately.
container | Socket container. | |
service | Service name or number as string. | |
address | Name or IP address as string. |
int ipv4_tcp_listen_hs | ( | struct socketContainer_t * | container, | |
short | service, | |||
char * | address, | |||
int | max | |||
) |
Listen to a TCP port A new socket is always created, so make sure that is closed appropriately.
container | Socket container. | |
service | Service number in host byte order. | |
address | Name or IP address as string (NULL gives 0.0.0.0). | |
max | Maximum number of clients to handle |
int ipv4_tcp_listen_ns | ( | struct socketContainer_t * | container, | |
short | service, | |||
char * | address, | |||
int | max | |||
) |
Listen to a TCP port A new socket is always created, so make sure that is closed appropriately.
container | Socket container. | |
service | Service number in network byte order. | |
address | Name or IP address as string (NULL gives 0.0.0.0). | |
max | Maximum number of clients to handle |
int ipv4_tcp_listen_ss | ( | struct socketContainer_t * | container, | |
char * | service, | |||
char * | address, | |||
int | max | |||
) |
Listen to a TCP port A new socket is always created, so make sure that is closed appropriately.
container | Socket container. | |
service | Service name or number as string. | |
address | Name or IP address as string (NULL gives 0.0.0.0). | |
max | Maximum number of clients to handle |
int ipv4_udp_bind_hs | ( | struct socketContainer_t * | container, | |
short | service, | |||
char * | address | |||
) |
Bind to an UDP port A new socket is always created, so make sure that is closed appropriately.
container | Socket container. | |
service | Service number in host byte order. | |
address | Name or IP address as string (NULL gives 0.0.0.0). |
int ipv4_udp_bind_ns | ( | struct socketContainer_t * | container, | |
short | service, | |||
char * | address | |||
) |
Bind to an UDP port A new socket is always created, so make sure that is closed appropriately.
container | Socket container. | |
service | Service number in network byte order. | |
address | Name or IP address as string (NULL gives 0.0.0.0). |
int ipv4_udp_bind_ss | ( | struct socketContainer_t * | container, | |
char * | service, | |||
char * | address | |||
) |
Bind to an UDP port A new socket is always created, so make sure that is closed appropriately.
container | Socket container. | |
service | Service name or number as string. | |
address | Name or IP address as string (NULL gives 0.0.0.0). |