I've created a very simple tcp\ip program using your basic send and recv
socket functions for WM 2003 SE. The sockets are set for blocking which is
fine, since they have their own thread, however if I loose connection the
socket just hangs forever. Is there a setting I can change that will stop
this(allow the socket to time out)?

I know I can create a non blocking socket to get around this, but this
solution seems more complex then its needs to be. Any suggestions?

Re: Sockets that won't stop by Dick

Dick
Fri Oct 07 12:54:14 CDT 2005

Hi,

If you want to use a blocking read, then you might want to do it like this:

If

Client.GetStream.DataAvailable = True Then

Try

Client.GetStream.Read(Buffer, 0, READ_BUFFER_SIZE)

RaiseEvent DataAvailable(Buffer) 'or whatever

Catch ex As Exception

End Try

End If

--
Richard Grier (Microsoft Visual Basic MVP)


See www.hardandsoftware.net for contact information.

Author of Visual Basic Programmer's Guide to Serial Communications, 4th
Edition ISBN 1-890422-28-2 (391 pages) published July 2004. See
www.mabry.com/vbpgser4 to order.