landingnormand
Member
- Joined
- Mar 26, 2009
- Messages
- 15
- Programming Experience
- Beginner
H,
Could someone explain to me how to do the following. I've been battling with this for ages and its driving me nuts.
I have a server app and a client app that communicate via TCP/IP using the sockets class. I'm using Asynchronous methods (i.e. BeginAccept, EndAccept, BeginReceive, EndReceive etc.) for greater scalability etc. I found a demo app that illustrates the asynchronous socket communication (very well) however its a relatively simple chat-type application where messages can be sent either by the client(s) or the server and are displayed at either end. There is no sequencing of messages or timeouts involved (see Asynchronous Socket Programming in C#: Part II - CodeGuru).
In my situation the basic flow (to begin with) is as follows:
1. When a client connects to the server I need to send a msg to the client asking for a username and password.
2. When the client receives this message it should send another message with said details.
3. In turn when the server receives this msg it should return another msg to the client to indicate success or failure.
What I dont know how to do is when I send a msg from the server how to introduce a timeout, i.e. if I dont get a response to this msg in 1 minute then close the connection to that particular client. The timeout must not effect or block other connections and there may be multiple timeouts in operation at any time as multiple clients can connect.
How do you deal with situations where you are effectively waiting for different responses from different clients?
Could someone explain to me how to do the following. I've been battling with this for ages and its driving me nuts.
I have a server app and a client app that communicate via TCP/IP using the sockets class. I'm using Asynchronous methods (i.e. BeginAccept, EndAccept, BeginReceive, EndReceive etc.) for greater scalability etc. I found a demo app that illustrates the asynchronous socket communication (very well) however its a relatively simple chat-type application where messages can be sent either by the client(s) or the server and are displayed at either end. There is no sequencing of messages or timeouts involved (see Asynchronous Socket Programming in C#: Part II - CodeGuru).
In my situation the basic flow (to begin with) is as follows:
1. When a client connects to the server I need to send a msg to the client asking for a username and password.
2. When the client receives this message it should send another message with said details.
3. In turn when the server receives this msg it should return another msg to the client to indicate success or failure.
What I dont know how to do is when I send a msg from the server how to introduce a timeout, i.e. if I dont get a response to this msg in 1 minute then close the connection to that particular client. The timeout must not effect or block other connections and there may be multiple timeouts in operation at any time as multiple clients can connect.
How do you deal with situations where you are effectively waiting for different responses from different clients?