NAME

xbind - add an endpoint to the socket, local or remote

SYNOPSIS

#include <xio/socket.h>

int xbind (int s, const char *addr);

DESCRIPTION

xbind() assigns the address specified to by addr to the socket referred to by s. if the xio socket type is XLISTENER, it is the same as xlisten[3]. or if the xio socket’s type is XCONNECTOR, it is the same as xconnect[3].

The addr is specific to the underlying transport protocol.

Maximum length of the addr parameter is specified by XSOCKADDRLEN defined in <xio/socket.h> header file.

RETURN VALUE

On success, zero is returned. On error, -1 is returned, and errno is set appropriately.

ERRORS

EBADF

The provided socket is invalid.

EINVAL

The syntax of the supplied address is invalid.

ENODEV

Address specifies a nonexistent interface.

EADDRINUSE

The requested local endpoint is already in use.

EXAMPLE

s = xsocket (XPF_TCP, XLISTENER);
assert (xbind (s, "192.168.1.2:8080") == 0);

same as:
s = xlisten("tcp://192.168.1.2:8080");


s = xsocket (XPF_TCP, XCONNECTOR);
assert (xbind (s, "192.168.1.2:8080") == 0);

same as:
s = xconnect("tcp://192.168.1.2:8080");

SEE ALSO

xpf_inproc(7) xpf_ipc(7) xpf_tcp(7) xsocket(3) xlisten(3) xconnect(3) xclose(3) xio(7)

AUTHORS

Dong Fang <yp.fangdong@gmail.com>
Martin Sustrik <sustrik@250bpm.com>