AnsweredAssumed Answered

Is it ok to call accept() in a child task that did NOT create the listening socket?

Question asked by Joel Fieber on Apr 28, 2015
Latest reply on Apr 30, 2015 by Garabo

Is it ok to call accept() in a child task that did NOT create the listening socket?

 

The MQX example code I've seen for daemon type servers (a server task (daemon) owns the listening socket and spawns a child task to connect with new clients) always has the server task accept() the connection. Then the server task calls RTCS_detachsock() before spawning the child task, which calls RTCS_attachsock().

 

Are the RTCS_attachsock() and RTCS_detachsock() calls strictly necessary? Can the child task call accept() with the handle of the listening socket? It seems like this would automatically give ownership of the new socket to the child. But, I'm anticipating some kind of gotcha...

 

 

Cheers,

+Joel.

Outcomes