Hello !
I've got a question . I really don't het this point. Let's supose that I have a client connected to a server.
I want the server IMEDIATLY know if the client is diconnected . How can I realize this ?
Amd I'm just curios about one thing. I have a server and multiple clients connected to it. Yes , multithreading . Each client connects to 3 ports on the server. So for each client the server will be opening a socket descriptor .Let's take an example : ( the server is using 3 threads with select , for each socket - 3 ports).
Server will use 3 socket descriptors : 3,4,5 .
Client one will use ( the next ) : 6,7,8.
Client two will use : 9,10,11 .and so on so fort..
Client three will use : 12,13,14 ..
etc..
If , per example client 1 is disconnected ( from all 3 sockets ) , select from server ( all 3 threads ) will connect another client on : 6,7,8 , because they're free..
Good , what do I mean to ask ? How can I know which socket descriptors is using a client ? I mean where do I know client 1 is using : 6 , 7 , 8 ?
I mean a problem like this :
Client 1 is disconnected . But it only disconnect two sockets from the server , so 6,7 socket descriptors are free , but 8 remain full ( because the clients hasent's disconnected ).
So the server ( 3 threads ) with select on each will make the following thing.If another client is connected it will use : 6,7 and the the first free socket descritor in our example if 15.
So client 1 will have : 6,7,15 open socket descriptors at server side.
I want to know clearly on the server side , which socket descriptors numbers are used by each client. I cannot say that they're always be in a numbered way : n,n+1,n-1 . How can I know . Maybe is a stupid question , but ..