CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 20 of 20
  1. #16
    Join Date
    Nov 2002
    Location
    California
    Posts
    4,556

    Re: Socket's won't work remotely.

    ... So I believe the reason it won't work is because the server is binding to the localhost IP, and not the computer's IP address?
    No, if netstat -an shows that your server is LISTENING at 0.0.0.0, then you should be OK.

    Please review this thread and post the other information requested. I still don't understand your reluctance to show actual IPs. They should be private LAN IP's which are not routable, so there would never be a security issue. If they are actually public, routable IPs, then that's your problem, since the client can't find the server on the local LAN.

    Again, being ping'able is good, but it doesn't guarantee that both machines are on the same LAN.

    Does your server have two NICs?

  2. #17
    Join Date
    Mar 2007
    Posts
    20

    Re: Socket's won't work remotely.

    I believe that my IP's are private IP addresses. My server does not have two NICs. Both computers on the Local Network share the same IP address. Even if I have both the client and server program running on the same machine, it still doesn't work. Here is the exact output on both the server and client when I use my IP address (both client and server on the same machine):

    Client:
    Code:
    Welcome
    
    Commands:
    
     c - Connect to computer
     l - List commands
     e - Exit Program
    
    Command: c
    Enter user's IP Address: 68.60.14X.XX
    Enter port # to connect to: 6980
    Connected to 68.60.14X.XX:6980
    Socket initialized
    Connect failed, error: 10060
    Command:
    10060 is a timeout error

    Here is the server output:

    Code:
    Socket intialized...
    Socket unbound...
    Bind works...
    Listen works...
    Waiting for client...
    Last error... (0)
    And it just stays at that. When I try doing it with two separate computers on the same network sharing the same IP address, I get a 10061 error, connection forcefully rejected.

    once again, I am trying to get this to work very much like a webserver where anyone can connect from a computer NOT on the local network and access information.
    Last edited by tophat; March 2nd, 2008 at 10:44 AM.

  3. #18
    Join Date
    Nov 2002
    Location
    California
    Posts
    4,556

    Re: Socket's won't work remotely.

    Quote Originally Posted by tophat
    ... Both computers on the Local Network share the same IP address.
    This should not be possible and should be avoided even if it is possible. Each machine must have a unique IP address.
    ... Even if I have both the client and server program running on the same machine, it still doesn't work.
    This is very different from your first post, where you told us that "they work flawlessly together by binding the client to 127.0.0.1, or the localhost".

    I think you have probably changed your code considerably since you made your first post. For example, the code in your first post could not have produced the output you are showing now. Please zip up your project and post it here.

    Finally, the IP address that you show (which I am masking as 68.60.1xx.yy, so you can edit your post and preserve your privacy) is not a private IP address, it's public. You're a Comcast customer, correct? I wouldn't have been able to determine that if you gave a private IP address, but with a public IP adddress it's easy.

    At this stage of testing, you must use the private IP addresses that are local inside your LAN. At a command prompt for each machine, type "ipconfig". The IP address shown there is the address you should be trying to connect to. It should be something like 192.168.1.100. Post the output of ipconfig here, if you are not sure. If you are not seeing something like 192.168.1.100, then please tell us about your network configuration, i.e., the router/switch you are using, the modem/box with which you connect to the Internet, and how the Internet connection is shared with all others on the LAN.

    In addition, please re-run your ping tests with these private IP addresses, to make certain that each machine is ping'able from the other.

    Mike

  4. #19
    Join Date
    Mar 2007
    Posts
    20

    Re: Socket's won't work remotely.

    Mike, thanks again for all of your help!

    The program still works by using 127.0.0.1 within the local network, what I meant in my last post was that by using my public address it didn't work within the local network, which I see now is something that couldn't be done anyways.

    I ran ipconfig on the server machine, and here is the output:

    Code:
    C:\Documents and Settings\Erik>ipconfig
    
    Windows IP Configuration
    
    
    Ethernet adapter Local Area Connection:
    
            Connection-specific DNS Suffix  . : hsd1.mi.comcast.net.
            IP Address. . . . . . . . . . . . : 192.168.1.101
            Subnet Mask . . . . . . . . . . . : 255.255.255.0
            Default Gateway . . . . . . . . . : 192.168.1.1
    
    C:\Documents and Settings\Erik>
    Here is the ipconfig output for the client machine:

    Code:
    C:\Documents and Settings\Erik>ipconfig
    
    Windows IP Configuration
    
    
    Ethernet adapter Local Area Connection:
    
            Connection-specific DNS Suffix  . : hsd1.mi.comcast.net.
            IP Address. . . . . . . . . . . . : 192.168.1.103
            Subnet Mask . . . . . . . . . . . : 255.255.255.0
            Default Gateway . . . . . . . . . : 192.168.1.1
    
    C:\Documents and Settings\Erik>
    i connected to the server successfully (192.168.1.101) and received the server response .

    Now how can I get this program to use public IP's so someone that's not on the network can connect to the server with the client program?

  5. #20
    Join Date
    Nov 2002
    Location
    California
    Posts
    4,556

    Re: Socket's won't work remotely.

    Good. Phase one is completed: you are able to connect internally of the LAN.

    And from the looks of your ipconfig output, your gateway is probably a router (Linksys, D-Link etc) that all machines on the LAN connect to, and which has a "special" connector for connecting a modem/cable box that gives shared access for all LAN machines to the Internet. Correct?

    If so, then the important thing to understand is that your public (Comcast) IP is the IP address of the modem, not of any of the machines in your LAN.

    Your modem is smart enough to send incoming connection requests to the router. (Since the modem is connected to only one device, it doesn't take much brains to do so.) The router, therefore, must be told what it should do with incoming connections.

    That's where port-forwarding comes in. It's the exact same issues that Spasm mentioned many days ago, in his first post.

    You must configure your router to forward incoming connection requests for the port your server is listening on, to the LAN address of the machine where the server is located. For your system, you must configure the router to forward incoming requests for port 6980 over to the machine located at 192.168.1.101

    Your router probably has a convenient HTTP interface, for entering these settings, which you can find at http://192.168.1.1/ . If you do not understand how to effect these settings, then go to www.portforward.com , find the model of your router, and then follow the directions there.

    Once the port forwarding is set, then remote users on the Internet can connect to your machine using the public IP address of your modem/router. They will need to enter the dotted numerical IP address.

    Mike

Page 2 of 2 FirstFirst 12

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

Featured