Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 627037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:29:05+00:00 2026-05-13T19:29:05+00:00

I am trying to create a Socket Hello World program. I would ideally like

  • 0

I am trying to create a Socket “Hello World” program.

I would ideally like to create two programs who can exchange simple text, peer-to-peer.

I can create a webservice that the peers can post their IP Address to.

One peer can then select another to pair up with.

If one of the peers is my desktop computer, and the other is my laptop, how can I differentiate the two?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T19:29:05+00:00Added an answer on May 13, 2026 at 7:29 pm

    First of all. If all this is on your local network, without any NAT gateways or similar – it’s no big deal. Your server will see your clients with different IP addresses, and the clients can connect directly to each other.

    On the other hand, if your server runs on an internet reachable IP address, and your clients connect from wherever they can reach that server you will have to consider the rest of this post.

    Client A connects to your server. There’s now a connection between:
    (ClientAIP:ClientAPort,ServerIP:ServerPort)

    Client B connects to to your server. There’s now a connection between:
    (ClientBIP:ClientBPort,ServerIP:ServerPort)

    If both your clients are behind the same NAT‘ed gatway, the server will see ClientAIP == ClientBIP.
    But ClientAPort will be different from ClientBPort. And that’s enough to to keeep up two connections to your server.

    Now the trouble comes if you want to pair two of them. Have the clients send you its internal IP address(And perhaps its internal port too so that could be used for extra verification.)

    You now know the clients (external) IP and their internal IP.
    These will be the scenarios:

    1. ClientAInternalIP == ClientAIP, ClientBinternalIP == ClientBIP. Great neither are behind a NAT gateway – select one of them to be a server and the other one to connect directly to it.

    2. ClientAInternalIP != ClientAIP, ClientBinternalIP == ClientBIP. ClientA is behind NAT, ClientB is not. Have ClientB be a server and ClientA connect diectly to ClientB

    3. ClientAInternalIP == ClientAIP, ClientBinternalIP != ClientBIP. Just the reverse case 2).

    4. ClientAInternalIP != ClientAIP, ClientBinternalIP != ClientBIP, but ClientAIP == ClientBIP . Special case – they’re both behind a NAT gateway but they’re on the same internal network. This is the same as case 1). Except the clients can communicate on their internal network instead of the internet.

    5. ClientAInternalIP != ClientAIP, ClientBinternalIP != ClientBIP. Both are behind NAT gatways. -You can’t have the connect to eachother – atleast not without asking someone to set up port forwarding on one of the gateways at the client. You’ll have to route the communication through your server. (Though there are routers/gateways providing APIs you might be able to use to programatically open port forwarding from a client site. It’s not widely available and probably locked down anyways).

    And even with the above scenarios there might be firewalls set up so clients can’t peer directly even if their real IP address is routable on the internet – you might need to fall back to routing through your server anyway.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 405k
  • Answers 405k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer At a guess the CRT is reporting a false positive… May 15, 2026 at 5:46 am
  • Editorial Team
    Editorial Team added an answer Since the modal is to be called from the code… May 15, 2026 at 5:46 am
  • Editorial Team
    Editorial Team added an answer If your onclick event returns true, your browser follows the… May 15, 2026 at 5:46 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.