nn_bind(3compat)

# nn_bind(3compat) Manual Page

## NAME

nn_bind - accept connections from remote peers (compatible API)

## SYNOPSIS

    #include <nanomsg/nn.h>

    int nn_bind(int sock, const char *url)

## DESCRIPTION

The `nn_bind()` function arranges for the socket sock to accept connections at the address specified by url. An identifier for this socket’s association with the url is returned to the caller on success. This identfier can be used with `nn_shutdown()` to remove the association later.

| This function is provided for API compatibility with legacy libnanomsg. Consider using the relevant modern API instead.

| The bind operation is performed asynchronously, and may not have completed before this function returns control to the caller.

| Only transports supported by legacy libnanomsg may be used with this function. In particular, only the schemes `tcp://`, `ipc://`, `inproc://`, and `ws://` are supported with this function. (Use the modern API to use other schemes.)

## RETURN VALUES

This function returns a positive identifier on success, and -1 on error.

## ERRORS

`EADDRINUSE` | The address specified by url is already in use.
`EADDRNOTAVAIL` | The address specified by url is not available.
`EBADF` | The socket sock is not open.
`EINVAL` | An invalid url was supplied.

## SEE ALSO

nn_connect(3compat), nn_errno(3compat), nn_shutdown(3compat), nn_socket(3compat), nn_compat(3compat), nng(7)