LIBSSDP
 All Classes Files Functions Variables Typedefs Macros
Classes | Typedefs | Functions
socket_helpers.h File Reference
#include <sys/socket.h>
#include "common_definitions.h"
Include dependency graph for socket_helpers.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  socket_conf_s
 

Typedefs

typedef struct socket_conf_s socket_conf_s
 

Functions

int set_send_timeout (SOCKET sock, int timeout)
 
int set_receive_timeout (SOCKET sock, int timeout)
 
int set_reuseaddr (SOCKET sock)
 
int set_reuseport (SOCKET sock)
 
int set_keepalive (SOCKET sock, BOOL keepalive)
 
int set_ttl (SOCKET sock, int family, int ttl)
 
int disable_multicast_loopback (SOCKET sock, int family)
 
int join_multicast_group (SOCKET sock, char *multicast_group, char *interface_ip)
 
SOCKET setup_socket (socket_conf_s *conf)
 

Detailed Description

Header file for socket_helpers.c.

Definition in file socket_helpers.h.

Typedef Documentation

typedef struct socket_conf_s socket_conf_s

A socket configuration. Used by setup_socket().

Function Documentation

int disable_multicast_loopback ( SOCKET  sock,
int  family 
)

Disable multicast loopback traffic for a socket.

Parameters
sockThe socket to disable it for.
familySocket IP type (AF_INET or AF_INET6).
Returns
0 on success, errno otherwise.

Definition at line 118 of file socket_helpers.c.

int join_multicast_group ( SOCKET  sock,
char *  multicast_group,
char *  interface_ip 
)

Join a multicast group.

Parameters
multicast_groupThe group to join.
interface_ipThe interface to join on.
Returns
0 on success, errno otherwise.

Definition at line 135 of file socket_helpers.c.

int set_keepalive ( SOCKET  sock,
BOOL  keepalive 
)

Set the keepalive for a socket.

Parameters
sockThe socket to enable keepalive for.
keepaliveTRUE to enable keepalive for this socket, FALSE to disable it.
Returns
0 on success, errno otherwise.

Definition at line 93 of file socket_helpers.c.

int set_receive_timeout ( SOCKET  sock,
int  timeout 
)

Set the recv-timeout for a socket.

Parameters
sockThe socket to set the timeout for.
timeoutThe timeout value to set.
Returns
0 on success, errno otherwise.

Definition at line 48 of file socket_helpers.c.

int set_reuseaddr ( SOCKET  sock)

Set the reuseaddr for a socket. This enables the socket to receive from an address already in use (address and port in linux >= 3.9).

Parameters
sockThe socket to set the reuseaddr for.
Returns
0 on success, errno otherwise.

Definition at line 64 of file socket_helpers.c.

int set_reuseport ( SOCKET  sock)

Set the reuseport for a socket. This enable socket to receive from a port already in use (no support in linux < 3.9).

Parameters
sockThe socket to set the reuseport for.
Returns
0 on success, errno otherwise.

Definition at line 75 of file socket_helpers.c.

int set_send_timeout ( SOCKET  sock,
int  timeout 
)

Set the send-timeout for a socket.

Parameters
sockThe socket to set the timeout for.
timeoutThe timeout value to set.
Returns
0 on success, errno otherwise.

Definition at line 32 of file socket_helpers.c.

int set_ttl ( SOCKET  sock,
int  family,
int  ttl 
)

Set the Time-To-Live (ttl) for a socket.

Parameters
sockThe socket to set the ttl for.
ttlThe ttl value to set.
Returns
0 on success, errno otherwise.

Definition at line 103 of file socket_helpers.c.

SOCKET setup_socket ( socket_conf_s conf)

Create and configure a new socket.

Parameters
confThe socket configuration to use when creating and configuring the socket.
Returns
A new socket.

Definition at line 375 of file socket_helpers.c.