By "block" I mean that when you call Socket.Accept, that call will not
return (i.e. block further exexuction of your code) until a connection
attempt is made (which is clearly beyond your control). If you want to
listen on more than one port, then you need to either call BeginAccept, or
create a thread for each port.
Dont want to sound pedantic, but in my world-view, clients dont listen to
servers, rather servers listen for clients (call me simplistic, but it works
for me).
Anyway, it sounds to me like you need to listen on two ports for servers 1
and 2, and have a third port fo sending to server 2 (but its possible I have
misunderstoon what you are trying to do).
Anyway, if you have a socket that is in currently waiting to accept, I dont
beleive you can then initiate an outgoing connection on it.
Nick.
Viola said:
Thank you Nick, for your response.
thread).
Could you please explain what you mean by 'block on the first call'?
I would be using TCP. I have a client, which listens to two servers,
server1 and server2. The client would listen on port1 for incoming data from
server1, and then process the data and pass it on to server2 through port2.
Server2 dials in to the client with some paramters and fetches data from the
client's database, (depending on the paramters passed,) and passes the same
back to server2. So, the client would be listening to port1 for data from
server1 and port2 for incoming calls from server2, so that the client would
process data on the client's database and send the processed data back to
server2.
In this scenario, can I have an application at the client to be listening
to port1 and port2 at the same time? Here port2 would be used to send data
(from server1) and receive requests (from server2). Can this be done and
what would be the best way to implement this?