Restarting a socket
-
Hi all. I'm migrating a VB6 application that uses sockets. There is a button that restablishes the connection. In VB6 it is as simple as socket.close and socket.connect, but in vb.net it doesn't work. I'm using that code to connect: endpoint = New IPEndPoint(IPAddress.Parse(host), port) Socket1 = Nothing Socket1 = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp) Socket1.Connect(endpoint) The code that works in VB6 is that: Socket1.Close Socket1.RemoteHost = host Socket1.RemotePort = port Socket1.Connect The exception I get is: No connection could be made because the target machine actively refused it What is wrong here?
Regards, Diego F.
-
Hi all. I'm migrating a VB6 application that uses sockets. There is a button that restablishes the connection. In VB6 it is as simple as socket.close and socket.connect, but in vb.net it doesn't work. I'm using that code to connect: endpoint = New IPEndPoint(IPAddress.Parse(host), port) Socket1 = Nothing Socket1 = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp) Socket1.Connect(endpoint) The code that works in VB6 is that: Socket1.Close Socket1.RemoteHost = host Socket1.RemotePort = port Socket1.Connect The exception I get is: No connection could be made because the target machine actively refused it What is wrong here?
Regards, Diego F.
-
Close socket in VB.NET code, before re-connect.
---------------------------- **** JOB23743 Submitted ****
-
I do that before doing socket1=nothing. Do you think the problem is in the server? It is not .NET code.
Regards, Diego F.
Hi, I had tried that connecting to google ip address but I didn't get any error. please let me know to what server you are connecting. also try the sample by connecting multiple times and reply me please.
EndPoint = New IPEndPoint(IPAddress.Parse("66.249.89.99"), 80) Socket1 = Nothing Socket1 = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp) Socket1.Connect(EndPoint)
Thanks, Kiran Kumar -
Hi, I had tried that connecting to google ip address but I didn't get any error. please let me know to what server you are connecting. also try the sample by connecting multiple times and reply me please.
EndPoint = New IPEndPoint(IPAddress.Parse("66.249.89.99"), 80) Socket1 = Nothing Socket1 = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp) Socket1.Connect(EndPoint)
Thanks, Kiran Kumar