At the moment I can connect to an IP, given that it is actually available, and I can transfer data across to the server, and back, using the System.Net.Sockets namespace.
However there are a couple of things I'm struggling with. The most annoying of which is trying to deal with connection timeouts. Is there a way I can set the timeout length (ideally don't want it too long, as I don't want it to freeze my program). I have tried using socketname.SendTimeout and socketname.RecieveTimeout, but am not sure of the correct ways to use these.
Second problem on the same note... how do I find a timeout once my program has connected to the server already?
Thanks in advance, here is the connection part of my code (client side).
Private Sub cmdConnect_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles cmdConnect.Click
If Connected = False Then
[b]clientSocket.SendTimeout(2000) 'unsure of quite how to use[/b]
clientSocket.Connect("192.168.1.67", 8888)
Connected = True
readData = LocalUserAlias & " Connected to Chat Server ..."
msg()
txtChat.Text = "Chramy Messenger - Server Connected ..."
serverStream = clientSocket.GetStream()
Dim outStream As Byte() = _
System.Text.Encoding.ASCII.GetBytes(LocalUserAlias + "$")
serverStream.Write(outStream, 0, outStream.Length)
serverStream.Flush()
Dim ctThread As Threading.Thread = _
New Threading.Thread(AddressOf getMessage)
ctThread.Start()
cmdConnect.Text = "Disconnect from Chramy Messenger!"
Else
clientSocket.Close()
Connected = False
End If
End Sub


Sign In
Create Account


Back to top









