Socket.Available : possible bug ?

D

dream machine

Hi all,
I'm try to check if the one client socket is really connected at my SocketServer .

I build Client Socket with BeginAccept() ,
and I want to receive data with BegenReceive() call !

The BeginReceive and BeginAccept work very nice .


<Code type="C#">
try
{
int byte_available = socket_client.Available();
socket_client.BeginReceive(par1,par2,par3,parN....);
}
catch (SocketException e)
{
Console.WriteLine("TheSocket Was Disconnected From server");
}
</Code>

The problem is that if my client was disconnected from server,
the .Available property don't build the SocketException :-(
For this reason the BeginReceive is called :-(

- what happened if the Client was disconnected AFTER the BeginReceive Call ?

I have try to check the .Available property before the .EndReceive() method ,
in this way I can do double check if the client was disconnected from server.

But the .Available return 0, always and the .EndReceive is Called !

Can anyone can explain me this problem ?

dm
 
R

Rich Blum

dream machine said:
Hi all,
I'm try to check if the one client socket is really connected at my SocketServer .


The problem is that if my client was disconnected from server,
the .Available property don't build the SocketException :-(
For this reason the BeginReceive is called :-(


But the .Available return 0, always and the .EndReceive is Called !
dm -

Do you know what version of the .NET Framework you are running
your programs on? The behavior of the Available property changed
between versions 1.0 and 1.1. Under version 1.0, Available returns a 0
if the remote host disconnects. In version 1.1, Available returns the
SocketException when the remote host disconnects. It sounds like you
are using .NET 1.0, and expecting the results from 1.1. Hope this
helps solve your problem.

Rich Blum - Author
"C# Network Programming" (Sybex)
http://www.sybex.com/sybexbooks.nsf/Booklist/4176
"Network Performance Open Source Toolkit" (Wiley)
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0471433012.html
 
D

dream machine

Do you know what version of the .NET Framework you are running

I have installed the v1.1 of SDK .
Now , I have found the other way to check if Client is Disconnect .

If .EndReceive() return 0 , the client was disconnect from server .

dm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top