NN_CONNECT(3compat)

πŸ“¦ version 1.11, in alpine 3.24

πŸ’… NN_CONNECT (3compat) β€” the nng reference manual, bestie edition πŸŽ€

okay so real talk, this one lives in the 3compat section of the NNG Reference Manual β€” it's the legacy-compatibility corner of the house, and it's giving "vintage but still slaps" ✨

✨ NAME ✨

nn_connect β€” connect to a remote peer (the compatible API version, iykyk) πŸ¦‹

🌸 SYNOPSIS 🌸

#include <nanomsg/nn.h>

int nn_connect(int sock, const char *url)

πŸ’– DESCRIPTION πŸ’–

So nn_connect() is the function that arranges for the socket sock to initiate a connection to a peer at the address specified by url. That's the whole vibe. 🫢

On success, it hands you back an identifier for this socket's association with the url β€” like a little friendship bracelet πŸŽ€ for that connection. Keep it! You can pass that identifier to nn_shutdown() later to remove the association when you're done.

Note β€” this function is here purely for API compatibility with legacy libnanomsg. Lowkey consider using the relevant modern API instead. ✨
Note β€” the connect operation is performed asynchronously, so it may not have completed by the time this function returns control to you. Basically it's out the door before the text is even delivered, no cap. πŸ’€
Important β€” only transports supported by legacy libnanomsg may be used with this function. Specifically, only the schemes tcp://, ipc://, inproc://, and ws:// are supported here. (If you want the other schemes, use the modern API, bestie. fr fr.)

πŸ‘‘ RETURN VALUES πŸ‘‘

This function returns a positive identifier on success, and -1 on error. That's it, that's the whole deal. πŸ“

πŸ”₯ ERRORS πŸ”₯

  • ECONNREFUSED β€” the connection attempt was refused. rude of them honestly 😭
  • EBADF β€” the socket sock is not open. girl. open the socket first πŸ’…
  • EINVAL β€” an invalid url was supplied.

🌈 SEE ALSO 🌈

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


πŸ¦‹ and that's the page!! source/version + date tea for the girlies keeping receipts: this bad boy is dated 2026-01-13 and belongs to NN_CONNECT(3compat) β€” periodt, go connect some sockets bestie πŸ’–β­πŸ§š

πŸ“¦ where this page comes from