noPollConn* nopoll_conn_new_with_socket ( noPollCtx ctx,
noPollConnOpts options,
int  socket,
const char *  host_ip,
const char *  host_port,
const char *  host_name,
const char *  get_url,
const char *  protocols,
const char *  origin 
)

Creates a new Websocket connection using a socket with a preestablished connection.

Parameters
ctxThe noPoll context to which this new connection will be associated.
optionsOptional configuration object. See nopoll_conn_opts_new and nopoll_conn_opts_set_ssl_protocol (for example).
socketSocket FD with an already established connection.
host_ipThe websocket server address to connect to.
host_portThe websocket server port to connect to. If NULL is provided, port 80 is used.
host_nameThis is the Host: header value that will be sent. This header is used by the websocket server to activate the right virtual host configuration. If null is provided, Host: will use host_ip value.
get_urlAs part of the websocket handshake, an url is passed to the remote server inside a GET method. This parameter allows to configure this. If NULL is provided, then / will be used.
originWebsocket origin to be notified to the server.
protocolsOptional protocols requested to be activated for this connection (an string of list of strings separated by a white space).

Socket ownership

noPoll takes full ownership. For noPoll, there's no difference between a noPollConn created using regular API or offloaded and then used with nopoll_conn_new_with_socket.

However, noPoll will not close anything unless you do it (see calls to nopoll_close_socket throughout the code).

For noPoll, ownership here means no one is reading/writing to that socket but noPoll.

Can socket passed be used with my favourite I/O loop mech?

Yes.

Will reading or writing from/to the socket make noPoll unsafe?

Yes. Only noPoll must read and write to that socket using provided public API. Writing/reading directly will break not only noPoll sync but also remote's peer.

References nopoll_false, and NOPOLL_TRANSPORT_IPV4.