Well, to make a long story short, I have written a client/server app that loads a few entries into a listbox and when a user clicks on one of those items, information about that item is sent to the client. It all works just fine until you try clicking quickly between items. My code looks something like this:
As I said, this works just fine until you start clicking quickly between items in the listbox. It always gets stuck at the Receive line and you have to kill the process. I have tried adding ReceiveTimeout, but when it times out, it also closes the connection, which might as well, kill the app because without the connection, it's useless. Is there anyway to force the socket to stop Receiving and continue execution without disconnecting the socket?
Thanks in advance for your help
BTW, I'm using Visual Studio 2005
VB.NET:
SERVER: (uses BeginReceive for async)
Sub onIncommingData(bytes() as byte, bytesRead as integer)
Dim data as string = ASCII.GetString(bytes, 0, bytesRead)
Select Case data
Case "01"
'do something
Case "02"
'do something else
End Select
End Sub
CLIENT:
Sub Listbox1_Click(...blah...)
Dim bytes(1023) as byte
sock.Send(ASCII.GetBytes("01"))
sock.Receive(bytes, 0, bytes.Length)
'load information from received data
End Sub
As I said, this works just fine until you start clicking quickly between items in the listbox. It always gets stuck at the Receive line and you have to kill the process. I have tried adding ReceiveTimeout, but when it times out, it also closes the connection, which might as well, kill the app because without the connection, it's useless. Is there anyway to force the socket to stop Receiving and continue execution without disconnecting the socket?
Thanks in advance for your help
BTW, I'm using Visual Studio 2005