Socket events in vb.net compact framework

From: Glen Brown (Brown_at_discussions.microsoft.com)
Date: 02/03/05


Date: Wed, 2 Feb 2005 19:09:01 -0800

Hi All,

I am developing a Client / Server App using Visual Studio 2003 and a Smart
Device App and a TCP/IP Socket connection.

I have discovered a major flaw in the Winsock2 implementation in .Net
framework that I have no work around for.

The issue is there are no events or work arounds (that work) for capturing
when a client socket goes away. The issue is also inherent in the server
side also for sending data. You don't know the socket has closed server side
until an attempt to send is made. The server problem is not that much of an
issue just annoying, as the client maintains the connection on our CDMA/GPRS
networks. With data being at a premium for this service, sending heartbeats
at short intervals for over 200 devices gets very expensive. If the socket
was to alert the client app when it is closed the client can then reconnect
and maintain a reliable efficient connection for message delivery.

Suggested work around (Does not work)

  Using the asycronous callback for begin receive (which I alread was), if
you fail to receive data in the callback function, the socket has most likely
gone away and you should test for reconnection. Unfortunately the callback
function is not called with 0 bytes received so there is no way to know the
connection has been dropped.

Does anyone have another work around that they have tested or is this a wait
until next version of winsock issue and hope something else has not been ?

This seams to me to be a fundamental flaw in the .net framework
implementation of winsock2 and one you would definately hope gets fixed asap.

Any help anyone could provide would be much appreciated.

Thanks,

Glen.



Relevant Pages

  • [PATCH 0/5] [RFC] AF_RXRPC socket family implementation [try #3]
    ... These patches together supply secure client-side RxRPC connectivity as a Linux ... kernel socket family. ... presentation side is left to the client. ... Each connection goes to a particular "service". ...
    (Linux-Kernel)
  • [PATCH 0/5] [RFC] AF_RXRPC socket family implementation
    ... These patches together supply secure client-side RxRPC connectivity as a Linux ... Make it possible for the client socket to be used to go to more than one ... Each connection goes to a particular "service". ...
    (Linux-Kernel)
  • [PATCH 0/5] [RFC] AF_RXRPC socket family implementation [try #2]
    ... These patches together supply secure client-side RxRPC connectivity as a Linux ... Make it possible for the client socket to be used to go to more than one ... Each connection goes to a particular "service". ...
    (Linux-Kernel)
  • Re: Writing a windows service with a socket interface.
    ... It's FAR easier than direct socket ... > and sends a response back to the client. ... Or perhaps if the IP address of the server was modified ... > connection open, I would implement a sort of connection pool of course. ...
    (microsoft.public.dotnet.framework)
  • Cable modem/router causes error 10054, "Connection was forcibly reset by remote host"
    ... If there is no activity on the socket for five minutes, ... no resets are issued by our server or anything else visible on the wire. ... same to be true with an FTP client accessing an FTP site totally unrelated ... client, made five unsuccessful attempts to use its existing connection, then ...
    (microsoft.public.win32.programmer.networks)

Loading