[noPoll] Closing listener prematurely

Félix xcodexif en xif.fr
Mar Feb 3 16:18:30 CET 2015


Hi,

I want to use a websocket server as a "one-time server".
More clearly : I set up a noPoll listener on a defined port and I wait for a client.
Once the client is connected, I want to close the listener to release the port and let other instances of my program to do the same thing.

For that I use this code :

nopoll_bool onConnReady (noPollCtx* wsctx, noPollConn* conn, noPollPtr data) {
	...
	noPollConn* listener = (noPollConn*)data;
	nopoll_conn_close(listener);
	...
	return true;
}
...
noPollConn* listener = nopoll_listener_new(wsctx, "0.0.0.0", port);
...
nopoll_ctx_set_on_ready(wsctx, &onConnReady, (noPollPtr)listener);

But when the connection is established, even after 'nopoll_conn_close(listener)', the listening port is still used by the process :

# lsof -i
COMMAND    PID   ...  NODE NAME
my_program 3428  ...  TCP  *:29800 (LISTEN)
my_program 3428  ...  TCP  [me]:29800->[client]:58908 (ESTABLISHED)
my_program 3428  ...  TCP  [me]:57345->[client]:29254 (ESTABLISHED)

Does the listener can release the port, or do I need to rethink everything ?
I didn't try creating my own listener. Maybe I should ?

Thanks in advance !

Félix Faisant - xif.fr

------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: <http://lists.aspl.es/pipermail/nopoll/attachments/20150203/972e245c/attachment.html>


Más información sobre la lista de distribución noPoll