1 #ifndef LIBSOCKET_LIBINETSOCKET_H_C1A9FFEDF5E94B2FB010A0FAA0E92A2F 2 #define LIBSOCKET_LIBINETSOCKET_H_C1A9FFEDF5E94B2FB010A0FAA0E92A2F 35 #include <sys/socket.h> 36 #include <sys/types.h> 40 #define LIBSOCKET_TCP 1 41 #define LIBSOCKET_UDP 2 43 #define LIBSOCKET_IPv4 3 44 #define LIBSOCKET_IPv6 4 46 #define LIBSOCKET_BOTH \ 49 #define LIBSOCKET_READ 1 50 #define LIBSOCKET_WRITE 2 52 #define LIBSOCKET_NUMERIC 1 61 char proto_osi3,
int flags);
64 const char* host,
const char* service,
67 char* src_host,
size_t src_host_len,
69 size_t src_service_len,
70 int recvfrom_flags,
int numeric);
76 const char* bind_port,
char proto_osi4,
77 char proto_osi3,
int flags);
79 size_t src_host_len,
char* src_service,
80 size_t src_service_len,
int flags,
int create_inet_server_socket(const char *bind_addr, const char *bind_port, char proto_osi4, char proto_osi3, int flags)
Create a TCP or UDP server socket.
int get_address_family(const char *hostname)
Look up which address families a host supports.
ssize_t sendto_inet_dgram_socket(int sfd, const void *buf, size_t size, const char *host, const char *service, int sendto_flags)
This function is the equivalent to sendto(2)
int destroy_inet_socket(int sfd)
Close a socket.
int create_multicast_socket(const char *group, const char *port, const char *local)
Create a datagram socket and join to the multicast group address.
int accept_inet_stream_socket(int sfd, char *src_host, size_t src_host_len, char *src_service, size_t src_service_len, int flags, int accept_flags)
Accept a connection attempt on a server socket.
int create_inet_stream_socket(const char *host, const char *service, char proto_osi3, int flags)
Create and connect a new TCP/IP socket.
int shutdown_inet_stream_socket(int sfd, int method)
Perform a shutdown(2) call on a socket.
int connect_inet_dgram_socket(int sfd, const char *host, const char *service)
Connect a UDP socket.
ssize_t recvfrom_inet_dgram_socket(int sfd, void *buffer, size_t size, char *src_host, size_t src_host_len, char *src_service, size_t src_service_len, int recvfrom_flags, int numeric)
Receive data from a UDP/IP socket.
int create_inet_dgram_socket(char proto_osi3, int flags)
Creates a new UDP/IP socket.