• Post Reply Bookmark Topic Watch Topic
  • New Topic

How can differentiate which output stream is for which client?

 
Sunil Bhambani
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a server developed which is able to handle multiple clients. I want to differentiate which output stream is for which client. How can this be done? I know that each client request will run in different thread, but then also there is a need that I have to map output stream with client. Is it possible? If yes, then how?

Hope to get a reply soon.


Regards
Sunil
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by "map"? Each thread would have a reference to exactly one stream (the one associated with that thread's port) - so there's no confusion about which stream each thread should use. Am I missing something?
 
Sunil Bhambani
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,

Thanks for replying.

As I said I know that each client connection would be running in a separate thread.

The whole scenario is as under:-

1. Say 3 clients are connected to the server.

2. I have a website where end user will login and request for an appointment.

3. This makes an entry in the database which is monitored by the Server.

4. Server comes to know that the request is for say XYZ client.

5. Server will check whether that client is online or not.

6. Suppose the client is online then on which output stream the server should send the data, since 3 clients are online.

That is the reason that I want a way to keep track of which client has which output stream.


Regards
Sunil
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't understand steps 4 through 6. The server code running in the thread associated with a particular client already knows which client it's dealing with. So what is it checking in step 5? The client is obviously online, or it couldn't just have sent a request. And there's no question which stream to send the response to, since there is only a single stream for each client.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!