VLC  3.0.0-git
Macros | Functions
Internet sockets
Collaboration diagram for Internet sockets:

Macros

#define net_errno   errno
 
#define net_Close(fd)   ((void)vlc_close(fd))
 
#define MSG_NOSIGNAL   0
 
#define net_Connect(a, b, c, d, e)   net_Connect(VLC_OBJECT(a), b, c, d, e)
 
#define net_ListenTCP(a, b, c)
 
#define net_ConnectTCP(a, b, c)   net_ConnectTCP(VLC_OBJECT(a), b, c)
 
#define net_Accept(a, b)   net_Accept(VLC_OBJECT(a), b)
 
#define net_ConnectDgram(a, b, c, d, e)   net_ConnectDgram(VLC_OBJECT(a), b, c, d, e)
 
#define net_OpenDgram(a, b, c, d, e, g)   net_OpenDgram(VLC_OBJECT(a), b, c, d, e, g)
 
#define net_Read(a, b, c, d)   net_Read(VLC_OBJECT(a),b,c,d)
 
#define net_Write(a, b, c, d)   net_Write(VLC_OBJECT(a),b,c,d)
 
#define net_Gets(a, b)   net_Gets(VLC_OBJECT(a),b)
 
#define net_Printf(o, fd, ...)   net_Printf(VLC_OBJECT(o),fd, __VA_ARGS__)
 
#define net_vaPrintf(a, b, c, d)   net_vaPrintf(VLC_OBJECT(a),b,c,d)
 

Functions

int vlc_socket (int pf, int type, int proto, bool nonblock)
 Creates a socket file descriptor. More...
 
int vlc_socketpair (int pf, int type, int proto, int fds[2], bool nonblock)
 Creates a pair of socket file descriptors. More...
 
int vlc_accept (int lfd, struct sockaddr *addr, socklen_t *alen, bool nonblock)
 Accepts an inbound connection request on a listening socket. More...
 
int net_Socket (vlc_object_t *obj, int family, int socktype, int proto)
 
int net_Connect (vlc_object_t *p_this, const char *psz_host, int i_port, int socktype, int protocol)
 
int * net_Listen (vlc_object_t *p_this, const char *psz_host, int i_port, int socktype, int protocol)
 
static int net_ConnectTCP (vlc_object_t *obj, const char *host, int port)
 
int net_AcceptSingle (vlc_object_t *obj, int lfd)
 
int net_Accept (vlc_object_t *, int *)
 Accepts an new connection on a set of listening sockets. More...
 
int net_ConnectDgram (vlc_object_t *p_this, const char *psz_host, int i_port, int hlim, int proto)
 
static int net_ConnectUDP (vlc_object_t *obj, const char *host, int port, int hlim)
 
int net_OpenDgram (vlc_object_t *p_this, const char *psz_bind, int i_bind, const char *psz_server, int i_server, int proto)
 
static int net_ListenUDP1 (vlc_object_t *obj, const char *host, int port)
 
void net_ListenClose (int *fd)
 
int net_Subscribe (vlc_object_t *obj, int fd, const struct sockaddr *addr, socklen_t addrlen)
 
int net_SetCSCov (int fd, int sendcov, int recvcov)
 net_SetCSCov: Sets the send and receive checksum coverage of a socket: More...
 
ssize_t net_Read (vlc_object_t *p_this, int fd, void *p_data, size_t i_data)
 
ssize_t net_Write (vlc_object_t *p_this, int fd, const void *p_data, size_t i_data)
 Writes data to a socket. More...
 
char * net_Gets (vlc_object_t *p_this, int fd)
 Reads a line from a file descriptor. More...
 
ssize_t net_Printf (vlc_object_t *p_this, int fd, const char *psz_fmt,...)
 
ssize_t net_vaPrintf (vlc_object_t *p_this, int fd, const char *psz_fmt, va_list args)
 
int vlc_close (int)
 Closes a file descriptor. More...
 

Detailed Description

Macro Definition Documentation

◆ MSG_NOSIGNAL

#define MSG_NOSIGNAL   0

◆ net_Accept

#define net_Accept (   a,
 
)    net_Accept(VLC_OBJECT(a), b)

◆ net_Close

#define net_Close (   fd)    ((void)vlc_close(fd))

◆ net_Connect

#define net_Connect (   a,
  b,
  c,
  d,
 
)    net_Connect(VLC_OBJECT(a), b, c, d, e)

Referenced by net_ConnectTCP().

◆ net_ConnectDgram

#define net_ConnectDgram (   a,
  b,
  c,
  d,
 
)    net_ConnectDgram(VLC_OBJECT(a), b, c, d, e)

Referenced by net_ConnectUDP().

◆ net_ConnectTCP

#define net_ConnectTCP (   a,
  b,
 
)    net_ConnectTCP(VLC_OBJECT(a), b, c)

◆ net_errno

#define net_errno   errno

◆ net_Gets

#define net_Gets (   a,
 
)    net_Gets(VLC_OBJECT(a),b)

◆ net_ListenTCP

#define net_ListenTCP (   a,
  b,
 
)
Value:
SOCK_STREAM, IPPROTO_TCP)
#define VLC_OBJECT(x)
Type-safe vlc_object_t cast.
Definition: vlc_common.h:491
int * net_Listen(vlc_object_t *p_this, const char *psz_host, int i_port, int socktype, int protocol)
Definition: io.c:106

Referenced by httpd_HostCreate().

◆ net_OpenDgram

#define net_OpenDgram (   a,
  b,
  c,
  d,
  e,
 
)    net_OpenDgram(VLC_OBJECT(a), b, c, d, e, g)

Referenced by net_ConnectUDP(), and net_ListenUDP1().

◆ net_Printf

#define net_Printf (   o,
  fd,
  ... 
)    net_Printf(VLC_OBJECT(o),fd, __VA_ARGS__)

◆ net_Read

#define net_Read (   a,
  b,
  c,
 
)    net_Read(VLC_OBJECT(a),b,c,d)

◆ net_vaPrintf

#define net_vaPrintf (   a,
  b,
  c,
 
)    net_vaPrintf(VLC_OBJECT(a),b,c,d)

◆ net_Write

#define net_Write (   a,
  b,
  c,
 
)    net_Write(VLC_OBJECT(a),b,c,d)

Function Documentation

◆ net_Accept()

int net_Accept ( vlc_object_t p_this,
int *  pi_fd 
)

Accepts an new connection on a set of listening sockets.

If there are no pending connections, this function will wait.

Note
If the thread needs to handle events other than incoming connections, you need to use poll() and net_AcceptSingle() instead.
Parameters
p_thisVLC object for logging and object kill signal
pi_fdlistening socket set
Returns
-1 on error (may be transient error due to network issues), a new socket descriptor on success.

References pollfd::events, pollfd::fd, msg_Err, net_AcceptSingle(), net_errno, poll(), POLLIN, pollfd::revents, and vlc_strerror_c().

◆ net_AcceptSingle()

int net_AcceptSingle ( vlc_object_t obj,
int  lfd 
)

◆ net_Connect()

int net_Connect ( vlc_object_t p_this,
const char *  psz_host,
int  i_port,
int  socktype,
int  protocol 
)

◆ net_ConnectDgram()

int net_ConnectDgram ( vlc_object_t p_this,
const char *  psz_host,
int  i_port,
int  hlim,
int  proto 
)

◆ net_ConnectTCP()

static int net_ConnectTCP ( vlc_object_t obj,
const char *  host,
int  port 
)
inlinestatic

References net_Connect.

◆ net_ConnectUDP()

static int net_ConnectUDP ( vlc_object_t obj,
const char *  host,
int  port,
int  hlim 
)
inlinestatic

References net_ConnectDgram, net_OpenDgram, and VLC_API.

Referenced by AddressCreate().

◆ net_Gets()

char* net_Gets ( vlc_object_t obj,
int  fd 
)

Reads a line from a file descriptor.

This function is not thread-safe; the same file descriptor I/O cannot be read by another thread at the same time (although it can be written to).

Note
This only works with stream-oriented file descriptors, not with datagram or packet-oriented ones.
Returns
nul-terminated heap-allocated string, or NULL on I/O error.

References msg_Err, unlikely, vlc_recv_i11e(), and vlc_strerror_c().

◆ net_Listen()

int* net_Listen ( vlc_object_t p_this,
const char *  psz_host,
int  i_port,
int  socktype,
int  protocol 
)

◆ net_ListenClose()

void net_ListenClose ( int *  fd)

◆ net_ListenUDP1()

static int net_ListenUDP1 ( vlc_object_t obj,
const char *  host,
int  port 
)
inlinestatic

◆ net_OpenDgram()

int net_OpenDgram ( vlc_object_t p_this,
const char *  psz_bind,
int  i_bind,
const char *  psz_server,
int  i_server,
int  proto 
)

◆ net_Printf()

ssize_t net_Printf ( vlc_object_t p_this,
int  fd,
const char *  psz_fmt,
  ... 
)

References net_vaPrintf().

◆ net_Read()

ssize_t net_Read ( vlc_object_t p_this,
int  fd,
void *  p_data,
size_t  i_data 
)

◆ net_SetCSCov()

int net_SetCSCov ( int  fd,
int  sendcov,
int  recvcov 
)

net_SetCSCov: Sets the send and receive checksum coverage of a socket:

Parameters
fdsocket
sendcovpayload coverage of sent packets (bytes), -1 for full
recvcovminimum payload coverage of received packets, -1 for full

< Unspecified error

< Unspecified error

References SOL_DCCP, SOL_UDPLITE, VLC_EGENERIC, VLC_SUCCESS, and VLC_UNUSED.

Referenced by net_ListenUDP1().

◆ net_Socket()

int net_Socket ( vlc_object_t obj,
int  family,
int  socktype,
int  proto 
)

◆ net_Subscribe()

int net_Subscribe ( vlc_object_t obj,
int  fd,
const struct sockaddr *  addr,
socklen_t  addrlen 
)

◆ net_vaPrintf()

ssize_t net_vaPrintf ( vlc_object_t p_this,
int  fd,
const char *  psz_fmt,
va_list  args 
)

References net_Write(), and vasprintf().

Referenced by net_Printf().

◆ net_Write()

ssize_t net_Write ( vlc_object_t obj,
int  fd,
const void *  buf,
size_t  len 
)

Writes data to a socket.

This blocks until all data is written or an error occurs.

This function is a cancellation point.

Returns
the total number of bytes written, or -1 if an error occurs before any data is written.

References msg_Err, MSG_NOSIGNAL, vlc_killed(), vlc_send_i11e(), vlc_strerror_c(), and vlc_testcancel().

Referenced by net_vaPrintf().

◆ vlc_accept()

int vlc_accept ( int  lfd,
struct sockaddr *  addr,
socklen_t *  alen,
bool  nonblock 
)

Accepts an inbound connection request on a listening socket.

This function creates a connected socket from a listening socket, much like the standard accept() function. However, the new file descriptor has the close-on-exec flag set atomically. See also vlc_socket().

Parameters
lfdlistening socket file descriptor
addrpointer to the peer address or NULL [OUT]
alenpointer to the length of the peer address or NULL [OUT]
nonblockwhether to put the new socket in non-blocking mode
Returns
a new file descriptor or -1 on error

References vlc_socket_setup().

Referenced by httpdLoop(), net_AcceptSingle(), and vlc_accept_i11e().

◆ vlc_close()

int vlc_close ( int  )

Closes a file descriptor.

This closes a file descriptor. If this is a last file descriptor for the underlying open file, the file is closed too; the exact semantics depend on the type of file.

Note
The file descriptor is always closed when the function returns, even if the function returns an error. The sole exception is if the file descriptor was not currently valid, and thus cannot be closed (errno will then be set to EBADF).
Parameters
fdfile descriptor
Returns
Normally, zero is returned. If an I/O error is detected before or while closing, the function may return -1. Such an error is unrecoverable since the descriptor is closed.

A nul return value does not necessarily imply that all pending I/O succeeded, since I/O might still occur asynchronously afterwards.

References unlikely.

Referenced by block_FilePath(), config_SaveConfigFile(), httpdLoop(), TsStorageNew(), vlc_fopen(), vlc_getProxyUrl(), vlc_poll_i11e_cleanup(), vlc_poll_i11e_inner(), and vlc_rand_init().

◆ vlc_socket()

int vlc_socket ( int  pf,
int  type,
int  proto,
bool  nonblock 
)

Creates a socket file descriptor.

This function creates a socket, similar to the standard socket() function. However, the new file descriptor has the close-on-exec flag set atomically, so as to avoid leaking the descriptor to child processes.

The non-blocking flag can also optionally be set.

Parameters
pfprotocol family
typesocket type
protonetwork protocol
nonblocktrue to create a non-blocking socket
Returns
a new file descriptor or -1 on error

References vlc_socket_setup().

Referenced by net_Socket(), and vlc_tls_SocketAddrInfo().

◆ vlc_socketpair()

int vlc_socketpair ( int  pf,
int  type,
int  proto,
int  fds[2],
bool  nonblock 
)

Creates a pair of socket file descriptors.

This function creates a pair of sockets that are mutually connected, much like the standard socketpair() function. However, the new file descriptors have the close-on-exec flag set atomically. See also vlc_socket().

Parameters
pfprotocol family
typesocket type
protonetwork protocol
nonblocktrue to create non-blocking sockets
Return values
0on success
-1on failure

References vlc_socket_setup().

Referenced by vlc_pipe(), and vlc_tls_SocketPair().