The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
p550 connected to a HMC KeesH AIX 4 02-13-2007 03:46 AM
HMC and Unix Box not connected KeesH AIX 3 02-09-2007 12:19 PM
SCO connected Monitors marcelious SCO 1 06-21-2006 11:24 AM
How can I get Information about who is connected??? Huch AIX 3 02-23-2006 01:09 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 12-29-2006
!_30's Avatar
Registered User
 

Join Date: Sep 2006
Location: Romania , Ploiesti
Posts: 37
Connected or not connected !

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).

Code:
 
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 ..

Last edited by !_30; 12-29-2006 at 10:31 AM.
Reply With Quote
Forum Sponsor
  #2  
Old 01-21-2007
XinU*'s Avatar
Registered User
 

Join Date: Jan 2005
Posts: 15
hello !
it is been a long time since u post your problem, so are u having same problems as mentioned ? or solved ? if not it might be a solution.
Reply With Quote
  #3  
Old 01-21-2007
!_30's Avatar
Registered User
 

Join Date: Sep 2006
Location: Romania , Ploiesti
Posts: 37
Same problem.

Which is the solution ? ( You were talking about ? ).
Reply With Quote
  #4  
Old 01-21-2007
XinU*'s Avatar
Registered User
 

Join Date: Jan 2005
Posts: 15
hello !

ok the solution to this is by means to implement an algorithm -a way- to take care of when the ports will open and when will close, so u will have track all the time of what is going on with the ports. there is no direct way to deal with it.

for example
in your approach
when a peer is connected u open 3 ports, make sure that when it disconnects, it frees up all the ports. no exept. so the u will have your n+1

as u may think there are numerous way to deal with this.
so the think u need to do is find "a way" in design lvl rather than digging out functions.

Last edited by XinU*; 01-21-2007 at 06:18 PM.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 07:10 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0