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

  • SEARCH
  • Home
  • 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 6948773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:52:01+00:00 2026-05-27T13:52:01+00:00

I am writing a custom p2p program that runs on port 4900. In some

  • 0

I am writing a custom p2p program that runs on port 4900. In some cases when the person is behind a router, this port is not accessible from the internet.

Is there an automatic way of enabling the access to the port from the internet. I am not really sure of how other p2p applications work.

Can anyone please throw some light on this?

  • 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-27T13:52:02+00:00Added an answer on May 27, 2026 at 1:52 pm

    P2P connectivity in a nutshell. Assume we’re talking about UDP here. The steps below can also be applied to TCP with some adjustments.

    1. Enumerate all your local IP addresses (usually only 1). Create a UDP socket on a given port number** for each adapter with an IP address.

    2. For each socket created in step 1, contact a STUN or TURN server with that same socket to discover your external IP address and to discover what the internal port number maps to outside of the NAT (it’s not always the same port value). That is, your local address 192.168.1.2:4900 might be 128.11.12.13:8888 to the outside world. And some NATs don’t always use the same port mapping when using the same local port to other IP addresses. TURN will also provide you a “relay address”. You can also use UPNP to get a port mapped address directly from your router, if it supports that protocol.

    3. Through a rendezvous service (SIP, XMPP, instant message, web service, email, cups with strings), publish your address candidate list to a service or send a notification to the other client that says, “hey, I want to connect with you”. This message includes all the “address candidates” (ip and port pairs) collected in steps 1 and 2.

    4. The remote client, upon receiving the invite to connect, performs step 1 and 2 above as well. Then sends back his candidate list through the same channel that he received the inviter’s candidate list on.

    5. Hole punching step. Both clients, start sending test messages over UDP to the other side’s address candidates and listening for the same messages on their end. Whenever a messages is received, reply back to the address from which it came. Eventually, the clients will discover that they have a pair of addresses that they can reliably send datagrams too. Typically, one endpoint makes the final decision on which address pair (sockets) to communicate with and the protocol facilitates this endpoint telling the other endpoint this decision.

    **- usually best to not to rely on a well known port for P2P clients. Because two clients behind the same NAT or firewall would not likely be able to use your software at the same time.

    Here is a quick summary of some technologies to explore.

    STUN – Is a simple server and protocol for clients behind a NAT/route to discover what their external IP and port mappings are.

    TURN is an expansion to STUN, but supports relaying for P2P connectivity scenarios where firewalls and NATs prevent direct connections.

    ICE is a set of steps by which STUN and TURN are used for setting up a P2P connection. ICE is a formal protocol for steps 1-5 above. Two excellent set of slides on ICE are here and here.

    WebRTC is a variant of the ICE standard as well as a reference library for make P2P sessions with STUN and TURN.

    UPNP + Internet Gateway Device Protocol – Some routers support this for hosts to automatically obtain port mappings.

    libnice is an open source C library for Linux (and might work on windows) that implements ICE.

    libjingle is another ICE implementation (in C++) from Google. For Windows and Linux.

    PJNATH is a library within the PJSIP suite of coding libraries. It is a good implementation of an ICE stack (C code) and has been ported to a lot of platforms. (Windows, Linux, Mac, iOS, Symbian, and soon Android).

    And finally, I have a blatant plug for you to use my STUN server code base.

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

Sidebar

Related Questions

I'm writing a custom deserializer that will deserialize a list by deserializing each of
I'm writing a custom Ant task that needs to accept a custom nested type.
I'm considering writing a custom IPermission implementation but am not clear as to how
I'm writing custom ActionFilterAttribute and trying to write some data directly into output stream
As part of writing custom command (COM-Visible dll with class that implements Interwoven command
Im writing custom docs for some java methods, and some of them are overloaded
I need help writing custom functions for my casio fx-9860g I have done this
I know I can do this by writing custom type descriptors etc., however given
I'm aware of writing custom attributes that decorate a method and get evaluated before
I created custom django-admin command. I use this tutorial Writing custom django-admin commands For

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.