Results 1 to 12 of 12

Thread: Winsock can only connect to localhost

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2010
    Posts
    61

    Winsock can only connect to localhost

    Please help

    Could it be because I don't have a port open?
    I'm using ports:
    12345
    12346
    12347
    12348
    12349
    12355
    12356
    Last edited by Magestickown; Sep 12th, 2010 at 02:30 AM.

  2. #2
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Winsock can only connect to localhost

    Please post the code you are using. Thank you!
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  3. #3

    Thread Starter
    Member
    Join Date
    Mar 2010
    Posts
    61

    Re: Winsock can only connect to localhost

    Quote Originally Posted by Nightwalker83 View Post
    Please post the code you are using. Thank you!
    Code:
    Winsock1.RemoteHost = txtIP
    Winsock1.RemotePort = txtPort
    
    Winsock2.RemoteHost = txtIP
    Winsock2.RemotePort = 12346
    
    Winsock3.RemoteHost = txtIP
    Winsock3.RemotePort = 12349
    
    Winsock4.RemoteHost = txtIP
    Winsock4.RemotePort = 12348
    
    Winsock5.RemoteHost = txtIP
    Winsock5.RemotePort = 12355
    
    Winsock6.RemoteHost = txtIP
    Winsock6.RemotePort = 12356
    
    Winsock1.Connect
    Winsock2.Connect
    Winsock3.Connect
    Winsock4.Connect
    Winsock5.Connect
    Winsock6.Connect

  4. #4
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Winsock can only connect to localhost

    You can find heaps of examples in the vb6 and earlier codebank on how to let winsock communicated between two or more computers.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  5. #5

    Thread Starter
    Member
    Join Date
    Mar 2010
    Posts
    61

    Re: Winsock can only connect to localhost

    Quote Originally Posted by Nightwalker83 View Post
    You can find heaps of examples in the vb6 and earlier codebank on how to let winsock communicated between two or more computers.
    it's all connected to one computer on said ports.

  6. #6
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Winsock can only connect to localhost

    You can find heaps of examples in the codebank (link below):

    http://www.vbforums.com/forumdisplay.php?f=43
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  7. #7
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: Winsock can only connect to localhost

    What exactly are you trying to do ?

    You are attempting to connect to whatever is in txtIP, so if you've entered "localhost" or the IP Address of the Local Machine in txtIP then Winsock will attempt to connect to whatever is Listening on the Local Machine on the Ports you specified.

  8. #8

    Thread Starter
    Member
    Join Date
    Mar 2010
    Posts
    61

    Re: Winsock can only connect to localhost

    Quote Originally Posted by Doogle View Post
    What exactly are you trying to do ?

    You are attempting to connect to whatever is in txtIP, so if you've entered "localhost" or the IP Address of the Local Machine in txtIP then Winsock will attempt to connect to whatever is Listening on the Local Machine on the Ports you specified.
    Sorry, to clarify; by "localhost" I mean 127.0.0.1.
    Yes.
    So if I enter..... Uh, 24.68.349.120 and there was a listening socket with said ports, it would connect, but it only will connect if it's listening on 127.0.0.1 and attempting to connect on 127.0.0.1. any other IP will not work

  9. #9
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: Winsock can only connect to localhost

    Yes, that's how TCP/IP works. You can't connect to a TCP/IP connection unless something is listening on that combination of IP Address and TCP Port Number.

    As I said before what exactly are you trying to do ?

    If, for instance, you're trying to connect to your external IP address from another computer you'll probably have to enable Port Forwarding for the Port(s) in question on your Router. Normally, in most Routers the not 'well known' ports are not forwarded by default.

    EDIT: If you're trying to connect to Computer A from Computer B on your local network then Computer A will listen on a Port and Computer B will connect to Computer A's IP address and the same Port number.

  10. #10

    Thread Starter
    Member
    Join Date
    Mar 2010
    Posts
    61

    Re: Winsock can only connect to localhost

    Quote Originally Posted by Doogle View Post
    Yes, that's how TCP/IP works. You can't connect to a TCP/IP connection unless something is listening on that combination of IP Address and TCP Port Number.

    As I said before what exactly are you trying to do ?

    If, for instance, you're trying to connect to your external IP address from another computer you'll probably have to enable Port Forwarding for the Port(s) in question on your Router. Normally, in most Routers the not 'well known' ports are not forwarded by default.
    Ohhh.. So I need to have made sure user server has port forwarded, or it won't connect?
    'Cause I just did as test with my friend (server). And it did not work. I cannot access my router so I cannot be the server (It's an access point).

  11. #11
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: Winsock can only connect to localhost

    Yes that's right.

  12. #12

    Thread Starter
    Member
    Join Date
    Mar 2010
    Posts
    61

    Re: Winsock can only connect to localhost

    Quote Originally Posted by Doogle View Post
    Yes that's right.
    Alright I'll get him to do that. Thank you!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width