Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Restarting a socket

Restarting a socket

Scheduled Pinned Locked Moved Visual Basic
questioncsharp
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Diego F
    wrote on last edited by
    #1

    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.

    N 1 Reply Last reply
    0
    • D 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.

      N Offline
      N Offline
      ne0h
      wrote on last edited by
      #2

      Close socket in VB.NET code, before re-connect.

      ---------------------------- **** JOB23743 Submitted ****

      D 1 Reply Last reply
      0
      • N ne0h

        Close socket in VB.NET code, before re-connect.

        ---------------------------- **** JOB23743 Submitted ****

        D Offline
        D Offline
        Diego F
        wrote on last edited by
        #3

        I do that before doing socket1=nothing. Do you think the problem is in the server? It is not .NET code.

        Regards, Diego F.

        K 1 Reply Last reply
        0
        • D Diego F

          I do that before doing socket1=nothing. Do you think the problem is in the server? It is not .NET code.

          Regards, Diego F.

          K Offline
          K Offline
          Kiran Kumar B
          wrote on last edited by
          #4

          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

          D 1 Reply Last reply
          0
          • K Kiran Kumar B

            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

            D Offline
            D Offline
            Diego F
            wrote on last edited by
            #5

            Ok, it has to be the server. I can connect and disconnect to that IP as many times as I want. My server is VB6 code.

            Regards, Diego F.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups