Public Sub InitializeConnection() Dim Addr As IPAddress = Nothing Try DONT_ACCEPT_REQUESTS = True CancelTimer.Start() 'Assign Addr to the user input (txtIP) Addr = Dns.GetHostEntry(ServerIP).AddressList(0) If Not Addr Is Nothing Then 'Create an endpoint Dim EP As New IPEndPoint(Addr, CInt(ServerPort)) 'Set up client: instantiate, beginconnect ClientSocket = New Socket(AddressFamily.InterNetwork, SocketType.Stream, _ ProtocolType.Tcp) ClientSocket.BeginConnect(EP, AddressOf ConnectCallBack, Nothing) ClientSocket.SendTimeout = 60 ClientSocket.ReceiveTimeout = 60 End If Catch Exp As Exception Exit Sub End Try End Sub
ServerIP, ServerPort are nothing but variables which are given value, but how I do this tends to be unnecessary information. The problem I face with this is that I am not able to configure properly routers to transfer to a specified computer for the server application. I check with the Utorrent port checker if the port is opened, after a start the program and it starts listening and it gives OK and also makes the program connect and disconnect again(because of the socket from the Utorrent port checker). With other words, when somebody has a static IP and they do not have a wall(software firewall or a router), there is no problem acting as a server. The problem comes when I want to be server and as you see the socket from the Utorrent port checkers arrives and reports that the port is opened but the client side just cannot get connected to the server side. Is there something in my code that can fail when it came across a router or another kind of a barrier?
Thanks in advance!