Hello all, I am hoping someone could point me in the right direction.
I am working on a project that requires my client socket to maintain an
active connection and reply to information form my server at long intervals.
The server "pings" the client on a regular basis when there has been no
activity in order to ascertain whether or not the connection is still active.
it sends the client a particular bit of information and waits for a
specified reply. If it does not receive that reply, it shuts its end of the
connection down.
The communication looks a bit like this: client connects, client sends some
identifying information to the server, after a period of time server sends
"ping" request to client, client responds with expected reply.
Except that I cannot, under any circumstances using the .NET socket
implementation, get this to work. The client and server can communicate fine
as long as the client had just sent information to the server. If, for
example, I want to send information to the server that communication works
fine -- but when the next time the server needs to "ping" the application,
the client does not seem to receive the communication.
I have tried async sockets, the Select function and the Poll function. For
testing, I have a very stripped down application -- it all runs in one
thread, and, in the case of the Poll and Select methodologies, the calls are
made within a while loop running in the main() function. I have verified
that the "pings" are being sent from the server, and I have encountered this
error with other languages (C and PERL).
For a variety of reasons related to the project requirements, I would prefer
to use C# for this code. Does anyone have any idea what I could be doing
wrong?
Thanks.