Async Socket IO Question



Hi all. I have been digging around trying to find an answer to a few
questions that are bugging me. I am hoping someone here can help.

1 - If you start an Async IO (BeginAccept) and the client hangs up what
happens? The docs really don't tell you one way or the other. In my local
testing many of the sockets are never getting released for some reason. I
am not seeing my delegate called. I used an Interlock increment on each
begin and a decrement on each delegate to track it and sometimes they come
through, and sometimes they don't. Very odd. What is the correct behavior?

2 - Why does the .Connected property not update? I have read the docs and
tried lots of tests. It still does not appear to work.

try
{
// Attempt to ensure we are still connected...
byte[] temp = { 0x00 };
// I tried blocking and non-blocking didn't make a difference
sp.Client.Blocking = false;
// This is the MS recommended way. It ALWAYS returns 0 for me and
connected is not updated.
int res = sp.Client.Send(temp, 0, 0);
// I added this as an additional test and the same thing happens.
Always get back 0.
res = sp.Client.Receive(temp, 0, SocketFlags.None);
// If we get here we are still connected and alive...
}
catch( SocketException e )
{
if( e.NativeErrorCode.Equals(10035) )
{
// Still connected - the call would black
}
else
{
// We are disconnected
TimeoutOccured(ref sp);
return (false);
}
}

This app is a socket server that has remote clients connect. I can manually
telnet to the app, watch it start a read, and then kill the telnet app. I
know the socket is gone. I look in the process list and telnet is gone.
But the reads and sends still report it is valid, and connected still
reports true.
I do this test above in my routine prior to calling the beginreceive (I
figure there is no use beginning a receive if the client hung up), and
before sending data. Doesn't seem to make a difference.

What am I doing wrong?


.



Relevant Pages

  • Re: Async Socket IO Question
    ... I think you're mostly bumping into Socket Timeout issues. ... If you kill the process of your client app, the TCP session isn't cleanly ... When your server sends to the client app, that send happens just fine (the ...
    (microsoft.public.dotnet.framework)
  • Re: Automated login, but run in a telnet console? possible?
    ... it took way too much resources for my embedded system. ... But I thought by simply automate login and select some console (telnet ... >> I have developed an embedded Linux system (app) which does its job well. ...
    (comp.os.linux.embedded)
  • Re: Linux and OS wide events
    ... I am new to Linux programming. ... app that needs to dispatch events using C++. ... Registration requests will cause the socket the request appeared on to be added to the list of sockets messages of the requested kind will be "broadcasted" to. ...
    (comp.os.linux.development.apps)
  • Re: WinForm App to Telnet Application
    ... appropriate commands through a button interface on my windows app. ... > Telnet has been around for a long time. ... Right now VS.NET is great for WinForm and Web applications. ...
    (microsoft.public.dotnet.framework)
  • CPU Usage 100%
    ... Socket connection, ... the refresh timers are only initiated when the data has been ... When I start the app, ... it seems my message handling procedure and it's ...
    (microsoft.public.win32.programmer.networks)