Skip to content
Advertisement

Control doesn’t move next to the select function

i am trying to implement a TCP server that accepts multiple client nodes. However, the control is just stuck at select() and not moving beyond that. This is my code:

JavaScript

However, the control never moves beyond the select statement. It just remain there even after i open a connection to the server with telnet:

JavaScript

Why it stuck there and how do i get the client socket with this?

Advertisement

Answer

Here is the manual of select.

The first parameter should not be zero, but be the highest file-descriptor that select should manage plus 1. In your case it’s:

JavaScript
Advertisement