include/sys/socket.h File Reference

#include <sys/types.h>

Include dependency graph for socket.h:

Go to the source code of this file.

Data Structures

struct  sockaddr
 Socket address. More...
struct  linger
 Structure used for manipulating linger option. More...

Defines

#define _ABLE_CLIB_SYS_SOCKET_H   1
#define SOCK_STREAM   1
 Socket will be a full-duplex reliable stream.
#define SOCK_DGRAM   2
 Socket will be unreliable message oriented.
#define SOCK_RAW   3
 Socket will be a raw connection.
#define SO_DEBUG   0x0001
 Turn on debugging info recording.
#define SO_ACCEPTCONN   0x0002
 Socket has had listen.
#define SO_REUSEADDR   0x0004
 Allow local address reuse.
#define SO_KEEPALIVE   0x0008
 Keep connections alive.
#define SO_DONTROUTE   0x0010
 Just use interface addresses.
#define SO_BROADCAST   0x0020
 Permit sending of broadcast msgs.
#define SO_USELOOPBACK   0x0040
 Bypass hardware when possible.
#define SO_LINGER   0x0080
 Linger on close if data present.
#define SO_OOBINLINE   0x0100
 Leave received OOB data in line.
#define SO_REUSEPORT   0x0200
 Allow local address & port reuse.
#define SO_DONTLINGER   (int)(~SO_LINGER)
#define SO_SNDBUF   0x1001
 Send buffer size.
#define SO_RCVBUF   0x1002
 Receive buffer size.
#define SO_SNDLOWAT   0x1003
 Send low-water mark.
#define SO_RCVLOWAT   0x1004
 Receive low-water mark.
#define SO_SNDTIMEO   0x1005
 Send timeout.
#define SO_RCVTIMEO   0x1006
 Receive timeout.
#define SO_ERROR   0x1007
 Get error status and clear.
#define SO_TYPE   0x1008
 Get socket type.
#define SO_CONTIMEO   0x1009
 Connect timeout.
#define SO_NO_CHECK   0x100a
 Don't create UDP checksum.
#define SOL_SOCKET   0xfff
 Options for socket level.
#define AF_UNSPEC   0
#define AF_INET   2
#define PF_INET   AF_INET
#define PF_UNSPEC   AF_UNSPEC
#define IPPROTO_IP   0
#define IPPROTO_TCP   6
#define IPPROTO_UDP   17
#define IPPROTO_UDPLITE   136
#define MSG_PEEK   0x01
 Peeks at an incoming message.
#define MSG_WAITALL   0x02
 Requests that the function block until the full amount of data requested can be returned.
#define MSG_OOB   0x04
 Requests out-of-band data.
#define MSG_DONTWAIT   0x08
 Nonblocking i/o for this operation only.
#define TCP_NODELAY   0x01
 don't delay send to coalesce packets.
#define TCP_KEEPALIVE   0x02
 send KEEPALIVE probes when idle for pcb->keep_idle milliseconds.
#define TCP_KEEPIDLE   0x03
 set pcb->keep_idle - Same as TCP_KEEPALIVE, but use seconds for get/setsockopt.
#define TCP_KEEPINTVL   0x04
 set pcb->keep_intvl - Use seconds for get/setsockopt.
#define TCP_KEEPCNT   0x05
 set pcb->keep_cnt - Use number of probes sent for get/setsockopt.
#define IPTOS_TOS_MASK   0x1E
#define IPTOS_TOS(tos)   ((tos) & IPTOS_TOS_MASK)
#define IPTOS_LOWDELAY   0x10
#define IPTOS_THROUGHPUT   0x08
#define IPTOS_RELIABILITY   0x04
#define IPTOS_LOWCOST   0x02
#define IPTOS_MINCOST   IPTOS_LOWCOST
#define IPTOS_PREC_MASK   0xe0
#define IPTOS_PREC(tos)   ((tos) & IPTOS_PREC_MASK)
#define IPTOS_PREC_NETCONTROL   0xe0
#define IPTOS_PREC_INTERNETCONTROL   0xc0
#define IPTOS_PREC_CRITIC_ECP   0xa0
#define IPTOS_PREC_FLASHOVERRIDE   0x80
#define IPTOS_PREC_FLASH   0x60
#define IPTOS_PREC_IMMEDIATE   0x40
#define IPTOS_PREC_PRIORITY   0x20
#define IPTOS_PREC_ROUTINE   0x00
#define SHUT_RD   0
#define SHUT_WR   1
#define SHUT_RDWR   2

Functions

int socket (int domain, int type, int protocol)
 Create a network socket and return its file descriptor.
int accept (int sockfd, struct sockaddr *addr, socklen_t *addrlen)
 Accept a new connection on a socket.
int bind (int sockfd, const struct sockaddr *my_addr, socklen_t addrlen)
 Bind a socket to an address.
int shutdown (int sockfd, int how)
 Shut down part of a full-duplex connection.
int getpeername (int sockfd, struct sockaddr *name, socklen_t *namelen)
 Get name of connected peer socket.
int getsockname (int sockfd, struct sockaddr *name, socklen_t *namelen)
 Get socket name.
int getsockopt (int sockfd, int level, int optname, void *optval, socklen_t *optlen)
 Get options on a socket.
int setsockopt (int sockfd, int level, int optname, const void *optval, socklen_t optlen)
 Set options on a socket.
int connect (int sockfd, const struct sockaddr *name, socklen_t namelen)
 Initiate a connection on a socket.
int listen (int sockfd, int backlog)
 Listen for connections on a socket.
int recv (int sockfd, void *buf, int len, int flags)
 Receive a message from a socket.
ssize_t recvfrom (int sockfd, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen)
 Receive a message from a socket.
int send (int sockfd, const void *buf, int len, int flags)
 Send a message on a socket.
ssize_t sendto (int sockfd, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen)
 Send a message on a socket.


Define Documentation

#define _ABLE_CLIB_SYS_SOCKET_H   1

#define AF_INET   2

#define AF_UNSPEC   0

#define IPPROTO_IP   0

#define IPPROTO_TCP   6

#define IPPROTO_UDP   17

#define IPPROTO_UDPLITE   136

#define IPTOS_LOWCOST   0x02

#define IPTOS_LOWDELAY   0x10

#define IPTOS_MINCOST   IPTOS_LOWCOST

#define IPTOS_PREC ( tos   )     ((tos) & IPTOS_PREC_MASK)

#define IPTOS_PREC_CRITIC_ECP   0xa0

#define IPTOS_PREC_FLASH   0x60

#define IPTOS_PREC_FLASHOVERRIDE   0x80

#define IPTOS_PREC_IMMEDIATE   0x40

#define IPTOS_PREC_INTERNETCONTROL   0xc0

#define IPTOS_PREC_MASK   0xe0

#define IPTOS_PREC_NETCONTROL   0xe0

#define IPTOS_PREC_PRIORITY   0x20

#define IPTOS_PREC_ROUTINE   0x00

#define IPTOS_RELIABILITY   0x04

#define IPTOS_THROUGHPUT   0x08

#define IPTOS_TOS ( tos   )     ((tos) & IPTOS_TOS_MASK)

#define IPTOS_TOS_MASK   0x1E

#define MSG_DONTWAIT   0x08

Nonblocking i/o for this operation only.

#define MSG_OOB   0x04

Requests out-of-band data.

The significance and semantics of out-of-band data are protocol-specific.

#define MSG_PEEK   0x01

Peeks at an incoming message.

#define MSG_WAITALL   0x02

Requests that the function block until the full amount of data requested can be returned.

#define PF_INET   AF_INET

#define PF_UNSPEC   AF_UNSPEC

#define SHUT_RD   0

#define SHUT_RDWR   2

#define SHUT_WR   1

#define SO_ACCEPTCONN   0x0002

Socket has had listen.

#define SO_BROADCAST   0x0020

Permit sending of broadcast msgs.

#define SO_CONTIMEO   0x1009

Connect timeout.

#define SO_DEBUG   0x0001

Turn on debugging info recording.

#define SO_DONTLINGER   (int)(~SO_LINGER)

#define SO_DONTROUTE   0x0010

Just use interface addresses.

#define SO_ERROR   0x1007

Get error status and clear.

#define SO_KEEPALIVE   0x0008

Keep connections alive.

#define SO_LINGER   0x0080

Linger on close if data present.

#define SO_NO_CHECK   0x100a

Don't create UDP checksum.

#define SO_OOBINLINE   0x0100

Leave received OOB data in line.

#define SO_RCVBUF   0x1002

Receive buffer size.

#define SO_RCVLOWAT   0x1004

Receive low-water mark.

#define SO_RCVTIMEO   0x1006

Receive timeout.

#define SO_REUSEADDR   0x0004

Allow local address reuse.

#define SO_REUSEPORT   0x0200

Allow local address & port reuse.

#define SO_SNDBUF   0x1001

Send buffer size.

#define SO_SNDLOWAT   0x1003

Send low-water mark.

#define SO_SNDTIMEO   0x1005

Send timeout.

#define SO_TYPE   0x1008

Get socket type.

#define SO_USELOOPBACK   0x0040

Bypass hardware when possible.

#define SOCK_DGRAM   2

Socket will be unreliable message oriented.

#define SOCK_RAW   3

Socket will be a raw connection.

#define SOCK_STREAM   1

Socket will be a full-duplex reliable stream.

#define SOL_SOCKET   0xfff

Options for socket level.

#define TCP_KEEPALIVE   0x02

send KEEPALIVE probes when idle for pcb->keep_idle milliseconds.

#define TCP_KEEPCNT   0x05

set pcb->keep_cnt - Use number of probes sent for get/setsockopt.

#define TCP_KEEPIDLE   0x03

set pcb->keep_idle - Same as TCP_KEEPALIVE, but use seconds for get/setsockopt.

#define TCP_KEEPINTVL   0x04

set pcb->keep_intvl - Use seconds for get/setsockopt.

#define TCP_NODELAY   0x01

don't delay send to coalesce packets.


Function Documentation

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

Accept a new connection on a socket.

This call obtains the first connection request on the queue of pending connections, creates a new connected socket, and returns a new file descriptor referring to that socket. The newly created socket is not in the listening state. The original socket sockfd is unaffected by this call.

Parameters:
sockfd A file descriptor returned from socket .
addr An address structure which will be filled with the messages originator. This may be NULL if the message source is not required.
addrlen The length of the from socket address.
Returns:
A positive integer representing the accepted socket. On error -1 is returned and errno set.

int bind ( int  sockfd,
const struct sockaddr my_addr,
socklen_t  addrlen 
)

Bind a socket to an address.

Parameters:
sockfd A file descriptor returned from socket
my_addr The address to set for the local end of the socket.
addrlen The length of the my_addr socket address.
Returns:
On success, zero is returned. On error, -1 is returned, and errno is set appropriately.

int connect ( int  sockfd,
const struct sockaddr name,
socklen_t  namelen 
)

Initiate a connection on a socket.

Parameters:
sockfd A file descriptor returned from socket .
name The address to connect the socket to.
namelen The length of the connection address.
Returns:
0 on success or -1 on error and errno set.

int getpeername ( int  sockfd,
struct sockaddr name,
socklen_t namelen 
)

Get name of connected peer socket.

Parameters:
sockfd A file descriptor returned from socket
name An address structure which will be filled with the address of the peer the socket is connected to.
namelen The length of the name socket address.
Returns:
On success, zero is returned. On error, -1 is returned, and errno is set appropriately.

int getsockname ( int  sockfd,
struct sockaddr name,
socklen_t namelen 
)

Get socket name.

Parameters:
sockfd A file descriptor returned from socket
name An address structure which will be filled with the address of the local socket.
namelen The length of the name socket address.
Returns:
On success, zero is returned and the name contains the address of the local end of the socket. On error, -1 is returned, and errno is set appropriately.

int getsockopt ( int  sockfd,
int  level,
int  optname,
void *  optval,
socklen_t optlen 
)

Get options on a socket.

Parameters:
sockfd A file descriptor returned from socket
level The level at which the option is applied.
optname The option number passed to the appropriate protocol handler.
optval The options filled by the appropriate protocol handler.
optlen The length of options in /a optval.
Returns:
On success, zero is returned. On error, -1 is returned, and errno is set appropriately.

int listen ( int  sockfd,
int  backlog 
)

Listen for connections on a socket.

Parameters:
sockfd A file descriptor returned from socket .
backlog The maximum number of connections allowed on a socket.
Returns:
0 on success or -1 on error and errno set.

int recv ( int  sockfd,
void *  buf,
int  len,
int  flags 
)

Receive a message from a socket.

The recv call is identical to recvfrom with a NULL from parameter.

Parameters:
sockfd A file descriptor returned from socket .
buf The buffer to receive data into.
len The size of the receive buffer.
flags A set of flags which alter the reception behaviour.
Returns:
The number of bytes received or -1 and errno set.

ssize_t recvfrom ( int  sockfd,
void *  buf,
size_t  len,
int  flags,
struct sockaddr from,
socklen_t fromlen 
)

Receive a message from a socket.

This call is used to receive messages from a socket, and may be used to receive data on a socket whether or not it is connection-oriented.

Parameters:
sockfd A file descriptor returned from socket .
buf The buffer to receive data into.
len The size of the receive buffer.
flags A set of flags which alter the reception behaviour.
from An address structure which will be filled with the messages originator. This may be NULL if the message source is not required.
fromlen The length of the from socket address.
Returns:
The number of bytes received or -1 on error and errno set.

int send ( int  sockfd,
const void *  buf,
int  len,
int  flags 
)

Send a message on a socket.

The send call is equivalent to sendto with a NULL to parameter.

Parameters:
sockfd A file descriptor returned from socket .
buf A buffer containing the data to send.
len The length of the message to send.
flags The flags to alter how the message is sent.

ssize_t sendto ( int  sockfd,
const void *  buf,
size_t  len,
int  flags,
const struct sockaddr to,
socklen_t  tolen 
)

Send a message on a socket.

Parameters:
sockfd A file descriptor returned from socket .
buf A buffer containing the data to send.
len The length of the message to send.
flags The flags to alter how the message is sent.
to The address to send the message to may be NULL if the socket is already bound.
tolen The length of the to socket address.
Returns:
The number of characters sent or -1 and errno is set.

int setsockopt ( int  sockfd,
int  level,
int  optname,
const void *  optval,
socklen_t  optlen 
)

Set options on a socket.

Parameters:
sockfd A file descriptor returned from socket
level The level at which the option is applied.
optname The option number passed to the appropriate protocol handler.
optval The options passed to the appropriate protocol handler.
optlen The length of options in /a optval.
Returns:
On success, zero is returned. On error, -1 is returned, and errno is set appropriately.

int shutdown ( int  sockfd,
int  how 
)

Shut down part of a full-duplex connection.

Parameters:
sockfd A file descriptor returned from socket .
how A flag to control how the socket is to be shut down. If how is SHUT_RD, further receptions will be disallowed. If how is SHUT_WR, further transmissions will be disallowed. If how is SHUT_RDWR, further receptions and transmissions will be disallowed.
Returns:
On success, zero is returned. On error, -1 is returned, and errno is set appropriately.

int socket ( int  domain,
int  type,
int  protocol 
)

Create a network socket and return its file descriptor.

Parameters:
domain The communication domain typically PF_INET .
type The type of communications one of SOCK_STREAM , SOCK_DGRAM or SOCK_RAW .
protocol The protocol within the domain .
Returns:
A file descriptor for the new communication endpoint or -1 and errno is set.


Generated on Tue Jan 20 14:28:59 2009 for ABLE LIBC by  doxygen 1.5.6