Loading...
Searching...
No Matches
socket.h File Reference

Main socket header. More...

Detailed Description

Main socket header.

See also
The Open Group Base Specifications Issue 7, <sys/socket.h>
Todo:
Omitted from original specification for now:
  • struct msghdr, struct cmesghdr, and struct linger and all related defines
  • getsockopt()/setsockopt() and all related defines.
  • shutdown() and all related defines.
  • sockatmark()
Author
Martine Lenders mlend.nosp@m.ers@.nosp@m.inf.f.nosp@m.u-be.nosp@m.rlin..nosp@m.de

Definition in file socket.h.

#include <stdalign.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/uio.h>
#include "architecture.h"
#include "net/af.h"
#include "sys/bytes.h"
+ Include dependency graph for socket.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  sockaddr
 Used to define the socket address. More...
 
struct  sockaddr_storage
 Implementation based socket address table. More...
 

Macros

#define SOCKET_POOL_SIZE   (4)
 Maximum number of sockets available on for creation with socket()
 
#define SOCKET_TCP_QUEUE_SIZE   (0)
 Maximum number of incoming TCP connections a listening socket can handle.
 
#define SOCKADDR_MAX_DATA_LEN   (26)
 Maximum data length for a socket address.
 
#define SOL_SOCKET   (-1)
 Options to be accessed at socket level, not protocol level.
 

Typedefs

typedef unsigned short sa_family_t
 address family type
 

Functions

int accept (int socket, struct sockaddr *__restrict address, socklen_t *__restrict address_len)
 Accept a new connection on a socket.
 
int bind (int socket, const struct sockaddr *address, socklen_t address_len)
 Bind a name to a socket.
 
int connect (int socket, const struct sockaddr *address, socklen_t address_len)
 Connect a socket.
 
int getpeername (int socket, struct sockaddr *__restrict address, socklen_t *__restrict address_len)
 Get the name of the peer socket.
 
int getsockname (int socket, struct sockaddr *__restrict address, socklen_t *__restrict address_len)
 Get the socket name.
 
int listen (int socket, int backlog)
 Listen for socket connections and limit the queue of incoming connections.
 
ssize_t recvfrom (int socket, void *__restrict buffer, size_t length, int flags, struct sockaddr *__restrict address, socklen_t *__restrict address_len)
 Receive a message from a socket.
 
static ssize_t recv (int socket, void *buffer, size_t length, int flags)
 Receive a message from a connected socket.
 
ssize_t sendto (int socket, const void *buffer, size_t length, int flags, const struct sockaddr *address, socklen_t address_len)
 Send a message on a socket.
 
static ssize_t send (int socket, const void *buffer, size_t length, int flags)
 Send a message on a socket.
 
int socket (int domain, int type, int protocol)
 Create an endpoint for communication.
 

Socket types

#define SOCK_DGRAM   (1)
 Datagram socket.
 
#define SOCK_RAW   (2)
 Raw socket.
 
#define SOCK_SEQPACKET   (3)
 Sequenced-packet socket.
 
#define SOCK_STREAM   (4)
 Stream socket.
 

Option names

Option names for getsockopt() and setsockopt()

#define SO_ACCEPTCONN   (0)
 Socket is accepting connections.
 
#define SO_BROADCAST   (1)
 Transmission of broadcast messages is supported.
 
#define SO_DEBUG   (2)
 Debugging information is being recorded.
 
#define SO_DONTROUTE   (3)
 Bypass normal routing.
 
#define SO_ERROR   (4)
 Socket error status.
 
#define SO_KEEPALIVE   (5)
 Connections are kept alive with periodic messages.
 
#define SO_LINGER   (6)
 Socket lingers on close.
 
#define SO_OOBINLINE   (7)
 Out-of-band data is transmitted in line.
 
#define SO_RCVBUF   (8)
 Receive buffer size.
 
#define SO_RCVLOWAT   (9)
 Receive "low water mark".
 
#define SO_RCVTIMEO   (10)
 Receive timeout.
 
#define SO_REUSEADDR   (11)
 Reuse of local addresses is supported.
 
#define SO_SNDBUF   (12)
 Send buffer size.
 
#define SO_SNDLOWAT   (13)
 Send "low water mark".
 
#define SO_SNDTIMEO   (14)
 Send timeout.
 
#define SO_TYPE   (15)
 Socket type.
 
static int getsockopt (int socket, int level, int option_name, void *option_value, socklen_t *option_len)
 
int setsockopt (int socket, int level, int option_name, const void *option_value, socklen_t option_len)