Skip to content

Commit

Permalink
Generated from commit 085540aeada059918ed05499f677ee383aac1daa
Browse files Browse the repository at this point in the history
  • Loading branch information
Pusnow committed Feb 28, 2024
1 parent 9b89742 commit eba97b6
Show file tree
Hide file tree
Showing 14 changed files with 2,283 additions and 2,238 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if(WIN32)
message(
FATAL_ERROR
"WIN32 target is obsolete. Please use Windows Subsystems for Linux")
endif(WIN32)
endif()

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand Down Expand Up @@ -39,7 +39,7 @@ if(SANITIZER_FLAGS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SANITIZER_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SANITIZER_FLAGS}")
set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} ${SANITIZER_FLAGS}")
endif(SANITIZER_FLAGS)
endif()

# Compiler Test

Expand Down Expand Up @@ -253,6 +253,6 @@ if(DOXYGEN_FOUND)
${PROJECT_SOURCE_DIR}/doxygen/Doxyfile
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})

endif(DOXYGEN_FOUND)
endif()

include(cmake/kens-dist.cmake OPTIONAL)
203 changes: 102 additions & 101 deletions Documentation/man/accept.2.txt

Large diffs are not rendered by default.

115 changes: 58 additions & 57 deletions Documentation/man/bind.2.txt
Original file line number Diff line number Diff line change
@@ -1,99 +1,100 @@
BIND(2) Linux Programmer's Manual BIND(2)
BIND(2) Linux Programmer's Manual BIND(2)

NNAAMMEE
NAME
bind - bind a name to a socket

SSYYNNOOPPSSIISS
##iinncclluuddee <<ssyyss//ssoocckkeett..hh>>
SYNOPSIS
#include <sys/socket.h>

iinntt bbiinndd((iinntt _s_o_c_k_f_d,, ccoonnsstt ssttrruucctt ssoocckkaaddddrr **_a_d_d_r,,
ssoocckklleenn__tt _a_d_d_r_l_e_n));;
int bind(int sockfd, const struct sockaddr *addr,
socklen_t addrlen);

DDEESSCCRRIIPPTTIIOONN
When a socket is created with ssoocckkeett(2), it exists in a name space (address family) but has no address
assigned to it. bbiinndd() assigns the address specified by _a_d_d_r to the socket referred to by the file
descriptor _s_o_c_k_f_d. _a_d_d_r_l_e_n specifies the size, in bytes, of the address structure pointed to by _a_d_d_r.
Traditionally, this operation is called “assigning a name to a socket”.
DESCRIPTION
When a socket is created with socket(2), it exists in a name space (address family) but has no ad‐
dress assigned to it. bind() assigns the address specified by addr to the socket referred to by the
file descriptor sockfd. addrlen specifies the size, in bytes, of the address structure pointed to
by addr. Traditionally, this operation is called “assigning a name to a socket”.

It is normally necessary to assign a local address using bbiinndd() before a SSOOCCKK__SSTTRREEAAMM socket may receive
connections (see aacccceepptt(2)).
It is normally necessary to assign a local address using bind() before a SOCK_STREAM socket may re‐
ceive connections (see accept(2)).

The rules used in name binding vary between address families. Consult the manual entries in Section 7
for detailed information. For AAFF__IINNEETT, see iipp(7); for AAFF__IINNEETT66, see iippvv66(7); for AAFF__UUNNIIXX, see uunniixx(7);
for AAFF__AAPPPPLLEETTAALLKK, see ddddpp(7); for AAFF__PPAACCKKEETT, see ppaacckkeett(7); for AAFF__XX2255, see xx2255(7); and for AAFF__NNEETTLLIINNKK,
see nneettlliinnkk(7).
The rules used in name binding vary between address families. Consult the manual entries in Section
7 for detailed information. For AF_INET, see ip(7); for AF_INET6, see ipv6(7); for AF_UNIX, see
unix(7); for AF_APPLETALK, see ddp(7); for AF_PACKET, see packet(7); for AF_X25, see x25(7); and for
AF_NETLINK, see netlink(7).

The actual structure passed for the _a_d_d_r argument will depend on the address family. The _s_o_c_k_a_d_d_r
The actual structure passed for the addr argument will depend on the address family. The sockaddr
structure is defined as something like:

struct sockaddr {
sa_family_t sa_family;
char sa_data[14];
}

The only purpose of this structure is to cast the structure pointer passed in _a_d_d_r in order to avoid
The only purpose of this structure is to cast the structure pointer passed in addr in order to avoid
compiler warnings. See EXAMPLES below.

RREETTUURRNN VVAALLUUEE
On success, zero is returned. On error, -1 is returned, and _e_r_r_n_o is set to indicate the error.
RETURN VALUE
On success, zero is returned. On error, -1 is returned, and errno is set to indicate the error.

EERRRROORRSS
EEAACCCCEESS The address is protected, and the user is not the superuser.
ERRORS
EACCES The address is protected, and the user is not the superuser.

EEAADDDDRRIINNUUSSEE
EADDRINUSE
The given address is already in use.

EEAADDDDRRIINNUUSSEE
(Internet domain sockets) The port number was specified as zero in the socket address structure,
but, upon attempting to bind to an ephemeral port, it was determined that all port numbers in
the ephemeral port range are currently in use. See the discussion of
_/_p_r_o_c_/_s_y_s_/_n_e_t_/_i_p_v_4_/_i_p___l_o_c_a_l___p_o_r_t___r_a_n_g_e iipp(7).
EADDRINUSE
(Internet domain sockets) The port number was specified as zero in the socket address struc‐
ture, but, upon attempting to bind to an ephemeral port, it was determined that all port num‐
bers in the ephemeral port range are currently in use. See the discussion of
/proc/sys/net/ipv4/ip_local_port_range ip(7).

EEBBAADDFF _s_o_c_k_f_d is not a valid file descriptor.
EBADF sockfd is not a valid file descriptor.

EEIINNVVAALL The socket is already bound to an address.
EINVAL The socket is already bound to an address.

EEIINNVVAALL _a_d_d_r_l_e_n is wrong, or _a_d_d_r is not a valid address for this socket's domain.
EINVAL addrlen is wrong, or addr is not a valid address for this socket's domain.

EENNOOTTSSOOCCKK
The file descriptor _s_o_c_k_f_d does not refer to a socket.
ENOTSOCK
The file descriptor sockfd does not refer to a socket.

The following errors are specific to UNIX domain (AAFF__UUNNIIXX) sockets:
The following errors are specific to UNIX domain (AF_UNIX) sockets:

EEAACCCCEESS Search permission is denied on a component of the path prefix. (See also ppaatthh__rreessoolluuttiioonn(7).)
EACCES Search permission is denied on a component of the path prefix. (See also path_resolu‐
tion(7).)

EEAADDDDRRNNOOTTAAVVAAIILL
EADDRNOTAVAIL
A nonexistent interface was requested or the requested address was not local.

EEFFAAUULLTT _a_d_d_r points outside the user's accessible address space.
EFAULT addr points outside the user's accessible address space.

EELLOOOOPP Too many symbolic links were encountered in resolving _a_d_d_r.
ELOOP Too many symbolic links were encountered in resolving addr.

EENNAAMMEETTOOOOLLOONNGG
_a_d_d_r is too long.
ENAMETOOLONG
addr is too long.

EENNOOEENNTT A component in the directory prefix of the socket pathname does not exist.
ENOENT A component in the directory prefix of the socket pathname does not exist.

EENNOOMMEEMM Insufficient kernel memory was available.
ENOMEM Insufficient kernel memory was available.

EENNOOTTDDIIRR
ENOTDIR
A component of the path prefix is not a directory.

EERROOFFSS The socket inode would reside on a read-only filesystem.
EROFS The socket inode would reside on a read-only filesystem.

CCOONNFFOORRMMIINNGG TTOO
POSIX.1-2001, POSIX.1-2008, SVr4, 4.4BSD (bbiinndd() first appeared in 4.2BSD).
CONFORMING TO
POSIX.1-2001, POSIX.1-2008, SVr4, 4.4BSD (bind() first appeared in 4.2BSD).

NNOOTTEESS
For background on the _s_o_c_k_l_e_n___t type, see aacccceepptt(2).
NOTES
For background on the socklen_t type, see accept(2).

BBUUGGSS
BUGS
The transparent proxy options are not described.

EEXXAAMMPPLLEESS
An example of the use of bbiinndd() with Internet domain sockets can be found in ggeettaaddddrriinnffoo(3).
EXAMPLES
An example of the use of bind() with Internet domain sockets can be found in getaddrinfo(3).

The following example shows how to bind a stream socket in the UNIX (AAFF__UUNNIIXX) domain, and accept
The following example shows how to bind a stream socket in the UNIX (AF_UNIX) domain, and accept
connections:

#include <sys/socket.h>
Expand Down Expand Up @@ -146,8 +147,8 @@ EEXXAAMMPPLLEESS
should be deleted using unlink(2) or remove(3). */
}

SSEEEE AALLSSOO
aacccceepptt(2), ccoonnnneecctt(2), ggeettssoocckknnaammee(2), lliisstteenn(2), ssoocckkeett(2), ggeettaaddddrriinnffoo(3), ggeettiiffaaddddrrss(3), iipp(7),
iippvv66(7), ppaatthh__rreessoolluuttiioonn(7), ssoocckkeett(7), uunniixx(7)
SEE ALSO
accept(2), connect(2), getsockname(2), listen(2), socket(2), getaddrinfo(3), getifaddrs(3), ip(7),
ipv6(7), path_resolution(7), socket(7), unix(7)

Linux 2021-03-22 BIND(2)
Linux 2021-03-22 BIND(2)
Loading

0 comments on commit eba97b6

Please sign in to comment.