socket.h

Overview

Related Modules:

NET

Description:

Provides functions and data structures related to network operations.

For example, you can use the functions to send and receive network data, manage network addresses, and convert bytes.

Since:

1.0

Version:

1.0

Summary

Data Structures

Data Structure Name

Description

sockaddr

Describes the socket address information.

Macros

Macro Name and Value

Description

SOL_SOCKET   1

Defines options for socket level.

Functions

Function Name

Description

socket (int domain, int type, int protocol)

int 

Creates a socket and returns its descriptor.

shutdown (int sockfd, int how)

int 

Shuts down a socket.

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

int 

Binds a local protocol address to a socket.

connect (int sockfd, const struct sockaddr addr, socklen_t addrlen)

int 

Initiates a connection to a socket.

listen (int sockfd, int backlog)

int 

Listens for network connections.

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

int 

Accepts incoming connection requests.

getsockname (int fd, struct sockaddr restrict addr, socklen_t restrict len)

int 

Retrieves the local address of the specified socket.

getpeername (int fd, struct sockaddr restrict addr, socklen_t restrict len)

int 

Retrieves the peer address of the specified socket.

send (int fd, const void buf, size_t len, int flags)

ssize_t 

Sends data to another socket.

recv (int fd, void buf, size_t len, int flags)

ssize_t 

Receives data from another socket.

sendto (int fd, const void buf, size_t len, int flags, const struct sockaddr addr, socklen_t alen)

ssize_t 

Sends data to another socket.

recvfrom (int fd, void *restrict buf, size_t len, int flags, struct sockaddr __restrict addr, socklen_t restrict alen)

ssize_t 

Receives data from a specified socket.

sendmsg (int fd, const struct msghdr msg, int flags)

ssize_t 

Sends data to another socket.

recvmsg (int fd, struct msghdr msg, int flags)

ssize_t 

Receives data from a specified socket.

getsockopt (int fd, int level, int optname, void *restrict optval, socklen_t __restrict optlen)

int 

Retrieves the socket options.

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

int 

Sets the socket options.