Networking code, makes my head hurt.
I am trying to create a class that implements a form of connectionless messaging.ÃÂ I have my DoSendMessage methodÃÂ ÃÂ that is using TCPClient.Connect but the problem is that if the server is not availible the Connect method hangs for about 5 secs while it tries to connect. Meaning my application also hangs. Very bad....
What I am looking for is a COMPLETE and WORKING sample that is simple and uses the asynronousÃÂ method for connecting usingÃÂ TCPClient.BeginConnect. But I have not been able to track down any easy to fallow sample code.
Does anybody know of any tutorials or links that can help me out. Thanks in advance!
MyÃÂ code is as fallows ...
Private Sub DoSendMessage(ByVal Server As IPAddress, ByVal Port As Integer, ByVal Message As String, ByVal Raiseevents As Boolean)
If Server Is Nothing Then Exit Sub
' If Server = String.Empty Or Message = String.Empty Then Exit Sub
' If Server.Contains(":") Then Server = Server.Substring(0, Server.IndexOf(":"))
' Create a TcpClient.
' Note, for this client to work you need to have a TcpServer
' connected to the same address as specified by the server, port
Dim client As New TcpClient
client.ExclusiveAddressUse = False
View Complete Post