bobbynad Posted October 29, 2003 Posted October 29, 2003 Hello Please Let me know to connect the server using the free ports available at time from the client machine usings sockets. Quote
Leaders dynamic_sysop Posted October 29, 2003 Leaders Posted October 29, 2003 you would need to catch a " port already in use " error ( then maybe loop back to your connecting code to try a different port ) to test for an open / used port you could do something along these lines... Try Dim ip As System.Net.IPHostEntry = System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName()) Dim ipaddy As Net.IPAddress = ip.AddressList(0) Dim ep As New Net.IPEndPoint(ipaddy, 80) Dim listner As New Net.Sockets.TcpListener(ep) listner.Start() Catch ex As SocketException If ex.ErrorCode = 10048 Then '/// error number for Port already in use. MessageBox.Show("The port you attempted to connect to is already in use!") Else MessageBox.Show(ex.ErrorCode & " " & ex.Message) End If End Try Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.