unix_connect() instantiates and connects a client socket. unix_server() instantiates and binds a server socket. unix_accept() accepts an incoming connection from a server socket.
◆ unix_subproto_t
Unix domain socket types.Contains a list of the supported socket types in the Unix domain.
Enumerator |
---|
unix_subproto_stream | Connection-oriented streams.
|
unix_subproto_packet | Connectionless packets.
|
unix_subproto_seqpacket | Connection-oriented packets. Only from linux-2.6.4.
|
◆ unix_connect()
int unix_connect |
( |
int |
flags, |
|
|
const char * |
path, |
|
|
enum unix_subproto_t |
subproto |
|
) |
| |
Connect to a remote Unix domain server.
- Parameters
-
flags | Flags for connection. |
path | Path to the server socket. If the first character of the string is an ASCII null, then the server socket refers to the abstract namespace. |
subproto | Unix domain socket type. |
- Return values
-
-1 | on error (and see errno). |
file | descriptor of new client on success. |
Creates a Unix domain socket and connects it to a remote server using the socket type specified in subproto.
flags may contain GSL_NONBLOCK to specify non-blocking mode.
◆ unix_server()
int unix_server |
( |
int |
flags, |
|
|
const char * |
path, |
|
|
const char * |
owner, |
|
|
const char * |
group, |
|
|
int |
mode, |
|
|
enum unix_subproto_t |
subproto |
|
) |
| |
Create a Unix domain server socket.
- Parameters
-
flags | Flags for server socket. |
path | Path to the server socket. If the first character of the string is an ASCII null, then the server socket refers to the abstract namespace. |
owner | Owner name for chown (may be 0). |
group | Group name for chgrp (may be 0). |
mode | Mode number for chmod (-1 means 0666 - umask). |
subproto | Unix domain socket type. |
- Return values
-
-1 | on error (and see errno). |
file | descriptor of new server on success. |
Creates a Unix domain socket and binds it to a socket file using the details in path and, optionally, owner, group and mode (see gsl_set_perms()). Note the process's umask is temporarily altered during creation of the socket.
flags may contain GSL_NONBLOCK to specify non-blocking mode (this will only affect the server; newly-accepted clients may be either blocking or non-blocking).
- See also
- unix_accept().
◆ unix_accept()
int unix_accept |
( |
int |
flags, |
|
|
int |
fd |
|
) |
| |
Accept a client from a connection-oriented Unix domain server socket.
- Parameters
-
flags | Flags for client socket. |
fd | Server's file descriptor. |
- Return values
-
-1 | on error (and see errno). |
- Returns
- file descriptor of new client on success.
This function attempts to accept() a connection from Unix domain socket server. It will retry on any error except EAGAIN, which indicates that there are actually no more clients to accept. It should be called in a loop until it does this. If a persistent error occurs, -1 will be returned and the last error recorded in errno.
flags may contain GSL_NONBLOCK to specify that a newly-accepted client will be in non-blocking mode.