'\" t .\" Title: nn_connect .\" Author: [see the "AUTHOR(S)" section] .\" Generator: Asciidoctor 2.0.20 .\" Date: 2024-02-21 .\" Manual: nanomsg 1.2.1 .\" Source: \ \& .\" Language: English .\" .TH "NN_CONNECT" "3" "2024-02-21" "\ \&" "nanomsg 1.2.1" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0 .nh .ad l .de URL \fI\\$2\fP <\\$1>\\$3 .. .als MTO URL .if \n[.g] \{\ . mso www.tmac . am URL . ad l . . . am MTO . ad l . . . LINKSTYLE blue R < > .\} .SH "NAME" nn_connect \- add a remote endpoint to the socket .SH "SYNOPSIS" .sp \fB#include \fP .sp \fBint nn_connect (int \fIs\fP, const char \fI*addr\fP);\fP .SH "DESCRIPTION" .sp Adds a remote endpoint to the socket \fIs\fP. The library would then try to connect to the specified remote endpoint. .sp The \fIaddr\fP argument consists of two parts as follows: \fItransport\fP\f(CR://\fP\fIaddress\fP. The \fItransport\fP specifies the underlying transport protocol to use. The meaning of the \fIaddress\fP part is specific to the underlying transport protocol. .sp For the list of available transport protocols check the list on nanomsg(7) manual page. .sp Maximum length of the \fIaddr\fP parameter is specified by \fINN_SOCKADDR_MAX\fP defined in \fI\fP header file. .sp Note that nn_connect and nn_bind(3) may be called multiple times on the same socket thus allowing the socket to communicate with multiple heterogeneous endpoints. .SH "NOTE" .sp Unlike with traditional BSD sockets, this function operates asynchronously, and returns to the caller before the operation is complete. As a result, attempts to send data or receive data on the socket may not succeed until the underlying transport actually establishes the connection. Further, the connection may be lost, without any notification to the caller. The library will attempt to reconnect automatically in such an event. .SH "RETURN VALUE" .sp If the function succeeds positive endpoint ID is returned. Endpoint ID can be later used to remove the endpoint from the socket via nn_shutdown(3) function. .sp If the function fails negative value is returned and \fIerrno\fP is set to to one of the values defined below. .SH "ERRORS" .sp \fBEBADF\fP .RS 4 The provided socket is invalid. .RE .sp \fBEMFILE\fP .RS 4 Maximum number of active endpoints was reached. .RE .sp \fBEINVAL\fP .RS 4 The syntax of the supplied address is invalid. .RE .sp \fBENAMETOOLONG\fP .RS 4 The supplied address is too long. .RE .sp \fBEPROTONOSUPPORT\fP .RS 4 The requested transport protocol is not supported. .RE .sp \fBENODEV\fP .RS 4 Address specifies a nonexistent interface. .RE .sp \fBETERM\fP .RS 4 The library is terminating. .RE .SH "EXAMPLE" .sp .if n .RS 4 .nf .fam C s = nn_socket (AF_SP, NN_PUB); eid1 = nn_connect (s, "ipc:///tmp/test.ipc"); eid2 = nn_connect (s, "tcp://server001:5560"); .fam .fi .if n .RE .SH "SEE ALSO" .sp nn_inproc(7) nn_ipc(7) nn_tcp(7) nn_socket(3) nn_bind(3) nn_shutdown(3) nanomsg(7) .SH "AUTHORS" .sp \c .MTO "sustrik\(at250bpm.com" "Martin Sustrik" .MTO "garrett\(atdamore.org" "Garrett D\(cqAmore" ""