Samsung Internal API reference  2.0
Socket library API

Typedefs

typedef int socklen_t
 A type of width of at least 32 bits representing lengths in socket subsystem.
 

Functions

int accept (int sockfd, struct sockaddr *addr, socklen_t *addrlen)
 Accept a connection on a socket. More...
 
int bind (int sockfd, const struct sockaddr *addr, socklen_t addrlen)
 Bind a name to a socket. More...
 
int connect (int sockfd, const struct sockaddr *addr, socklen_t addrlen)
 Initiate a connection on a socket. More...
 
int getsockopt (int sockfd, int level, int optname, void *optval, socklen_t *optlen)
 Get options on socket. More...
 
int setsockopt (int sockfd, int level, int optname, const void *optval, socklen_t optlen)
 Set options on socket. More...
 
int listen (int sockfd, int backlog)
 Listen for connections on a socket. More...
 
int socket (int socket_family, int socket_type, int protocol)
 Create endpoint for communication. More...
 
ssize_t recv (int sockfd, void *buf, size_t len, int flags)
 Receive a message from a socket. More...
 
ssize_t send (int sockfd, const void *buf, size_t len, int flags)
 Send a message to a socket. More...
 
int socketpair (int socket_family, int socket_type, int protocol, int sv[2])
 Create a pair of connected sockets. More...
 
ssize_t recvmsg (int sockfd, struct msghdr *msg, int flags)
 Receive multipple message on a socket. More...
 
ssize_t sendmsg (int sockfd, struct msghdr *msg, int flags)
 Send multipple message on a socket. More...
 

Detailed Description

Function Documentation

int accept ( int  sockfd,
struct sockaddr *  addr,
socklen_t addrlen 
)

#include <sys/socket.h>

Accept a connection on a socket.

Parameters
[in]sockfdlistening socket descriptor
[in]addrpointer to a sockaddr structure
[in,out]addrlensize of structure pointed to by addr
Returns
nonnegative file descriptor for the accepted socket on success
-1 with errno on error
int bind ( int  sockfd,
const struct sockaddr *  addr,
socklen_t  addrlen 
)

#include <sys/socket.h>

Bind a name to a socket.

Parameters
[in]sockfdsocket descriptor
[in]addraddress to the socket
[in]addrlensize of the address structure
Returns
0 on success
-1 with errno on error
int connect ( int  sockfd,
const struct sockaddr *  addr,
socklen_t  addrlen 
)

#include <sys/socket.h>

Initiate a connection on a socket.

Parameters
[in]sockfdsocket descriptor
[in]addraddress to the socket
[in]addrlensize of the address structure
Returns
0 on success
-1 with errno on error
int getsockopt ( int  sockfd,
int  level,
int  optname,
void *  optval,
socklen_t optlen 
)

#include <sys/socket.h>

Get options on socket.

Parameters
[in]sockfdsocket descriptor
[in]levelsocket API level
[in]optnamespecified options
[in,out]optvalbuffer in which the value of the requested options are to be returned
[in,out]optlenthe size of the buffer pointed to by optval
Returns
0 on success
-1 with errno on error
int listen ( int  sockfd,
int  backlog 
)

#include <sys/socket.h>

Listen for connections on a socket.

Parameters
[in]sockfdsocket descriptor
[in]backlogmaximum length to which the queue of pending connections for sockfd may grow
Returns
0 on success
-1 with errno on error
ssize_t recv ( int  sockfd,
void *  buf,
size_t  len,
int  flags 
)

#include <sys/socket.h>

Receive a message from a socket.

Parameters
[in]sockfdsocket descriptor
[in]bufpointer to a message buffer
[in]lenmessage length
[in]flagstype of receiving
Returns
number of bytes received on success
-1 with errno on error
ssize_t recvmsg ( int  sockfd,
struct msghdr *  msg,
int  flags 
)

#include <sys/socket.h>

Receive multipple message on a socket.

Parameters
[in]sockfdsocket descriptor
[in]msgpointer to an array of msghdr structures
[in]flagstype of receiving
Returns
number of messages received in msg on success
-1 with errno on error
ssize_t send ( int  sockfd,
const void *  buf,
size_t  len,
int  flags 
)

#include <sys/socket.h>

Send a message to a socket.

Parameters
[in]sockfdsocket descriptor
[in,out]bufpointer to a message buffer
[in]lenmessage length
[in]flagstype of sending
Returns
number of bytes sent on success
-1 with errno on error
ssize_t sendmsg ( int  sockfd,
struct msghdr *  msg,
int  flags 
)

#include <sys/socket.h>

Send multipple message on a socket.

Parameters
[in]sockfdsocket descriptor
[out]msgpointer to an array of msghdr structures
[in]flagstype of sending
Returns
number of messages sent from msg on success
-1 with errno on error
int setsockopt ( int  sockfd,
int  level,
int  optname,
const void *  optval,
socklen_t  optlen 
)

#include <sys/socket.h>

Set options on socket.

Parameters
[in]sockfdsocket descriptor
[in]levelsocket API level
[in]optnamespecified options
[in]optvalbuffer in which the new value of the requested options is stored
[in]optlenthe size of the buffer pointed to by optval
Returns
0 on success
-1 with errno on error
int socket ( int  socket_family,
int  socket_type,
int  protocol 
)

#include <sys/socket.h>

Create endpoint for communication.

Parameters
[in]socket_familycommunication domain
[in]socket_typecommunication semantics specifier
[in]protocolparticular protocol to be used with the socket
Returns
nonnegative file descriptor for the new socket on success
-1 with errno on error
int socketpair ( int  socket_family,
int  socket_type,
int  protocol,
int  sv[2] 
)

#include <sys/socket.h>

Create a pair of connected sockets.

Parameters
[in]socket_familycommunication domain
[in]socket_typecommunication semantics specifier
[in]protocolparticular protocol to be used with the socket
[in]svfile descriptors
Returns
0 on success
-1 with errno on error