MPD
Functions
socket_util.h File Reference
#include <glib.h>

Go to the source code of this file.

Functions

char * sockaddr_to_string (const struct sockaddr *sa, size_t length, GError **error)
 Converts the specified socket address into a string in the form "IP:PORT".
 
int socket_bind_listen (int domain, int type, int protocol, const struct sockaddr *address, size_t address_length, int backlog, GError **error)
 Creates a socket listening on the specified address.
 

Function Documentation

char* sockaddr_to_string ( const struct sockaddr *  sa,
size_t  length,
GError **  error 
)

Converts the specified socket address into a string in the form "IP:PORT".

The return value must be freed with g_free() when you don't need it anymore.

Parameters
sathe sockaddr struct
lengththe length of #sa in bytes
errorlocation to store the error occuring, or NULL to ignore errors
int socket_bind_listen ( int  domain,
int  type,
int  protocol,
const struct sockaddr *  address,
size_t  address_length,
int  backlog,
GError **  error 
)

Creates a socket listening on the specified address.

This is a shortcut for socket(), bind() and listen().

Parameters
domainthe socket domain, e.g. PF_INET6
typethe socket type, e.g. SOCK_STREAM
protocolthe protocol, usually 0 to let the kernel choose
addressthe address to listen on
address_lengththe size of #address
backlogthe backlog parameter for the listen() system call
errorlocation to store the error occuring, or NULL to ignore errors
Returns
the socket file descriptor or -1 on error