This documentation is for version v1.3.0 of NNG, but the latest released version is v1.8.0. see the documentation for v1.8.0 for the most up-to-date information.

SYNOPSIS

#include <nanomsg/nn.h>

int nn_socket(int af, int proto);

DESCRIPTION

The nn_socket() function creates socket using the address family af and protocol proto and returns it.

This function is provided for API compatibility with legacy libnanomsg. Consider using the relevant modern API instead.
Mixing the compatibility API and the modern API is not supported on a given socket.
Some protocols, transports, and features are only available in the modern API.

The address family af can be one of two values:

AF_SP

Normal socket.

AF_SP_RAW

“Raw mode” socket.

The protocol indicates the protocol to be used when creating the socket. The following protocols are defined:

NN_PAIR

Pair protocol.

NN_PUB

Publisher protocol.

NN_SUB

Subscriber protocol.

NN_REQ

Requestor protocol.

NN_REP

Replier protocol.

NN_PUSH

Push protocol.

NN_PULL

Pull protocol.

NN_SURVEYOR

Surveyor protocol.

NN_RESPONDENT

Respondent protocol.

NN_BUS

Bus protocol.

RETURN VALUES

This function returns a valid socket number on success, and -1 on failure.

ERRORS

ENOMEM

Insufficient memory is available.

ENOTSUP

The protocol is not supported.

ETERM

The library is shutting down.