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. Peep2peer, choose ports for TCP

Peep2peer, choose ports for TCP

Scheduled Pinned Locked Moved Visual Basic
helpquestion
3 Posts 2 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
    DK KiloDunse
    wrote on last edited by
    #1

    I’m trying to make a peer2peer program which can upload/download several files at the time. But how do I know witch ports to use??? I use one port to send information for commands, file size, and so on….. port 7070. The sender program can use any port but the receiver program may not be able to use that port. How do i resolve that problem????? And remember, there could be 3 or 5 files to send/receive. And how do i deal with firewalls and routers??? Please help.

    F 1 Reply Last reply
    0
    • D DK KiloDunse

      I’m trying to make a peer2peer program which can upload/download several files at the time. But how do I know witch ports to use??? I use one port to send information for commands, file size, and so on….. port 7070. The sender program can use any port but the receiver program may not be able to use that port. How do i resolve that problem????? And remember, there could be 3 or 5 files to send/receive. And how do i deal with firewalls and routers??? Please help.

      F Offline
      F Offline
      Fade Amit BS
      wrote on last edited by
      #2

      First of all, Don't Panic :) Basicly what you need to do is pretty simple. First, decide on one port number (for instance 7070 you mentioned), now both peers listen on that port, and both peers know that they are both listening on that port. When Peer A wants to send a file to Peer B, it creates a new socket (do not bind that socket to ANY port) and connects it to Peer B (by the known port). Now- Peer B will receive a 'Connection Request', and creates a new socket to accept the new connection. At this point, Peer A can send asorted information about the file it want to send like size, file name hash etc. and then begin to send the file. Because this is all happening on different sockets than the listening ones, both peers can initiate any additional number of connection as you wish (well not any number of connections but a reasonable one :) ) That's it, note that Peer A can also connect and Request a file from Peer B, the possibilities are endless. I can send you an example project i wrote with all this connection creation working, i will post it with an article, but it will take some time as i'm on a tight schedule now and can't write the article now. Let me know if you want the example. Fade (Amit BS)

      D 1 Reply Last reply
      0
      • F Fade Amit BS

        First of all, Don't Panic :) Basicly what you need to do is pretty simple. First, decide on one port number (for instance 7070 you mentioned), now both peers listen on that port, and both peers know that they are both listening on that port. When Peer A wants to send a file to Peer B, it creates a new socket (do not bind that socket to ANY port) and connects it to Peer B (by the known port). Now- Peer B will receive a 'Connection Request', and creates a new socket to accept the new connection. At this point, Peer A can send asorted information about the file it want to send like size, file name hash etc. and then begin to send the file. Because this is all happening on different sockets than the listening ones, both peers can initiate any additional number of connection as you wish (well not any number of connections but a reasonable one :) ) That's it, note that Peer A can also connect and Request a file from Peer B, the possibilities are endless. I can send you an example project i wrote with all this connection creation working, i will post it with an article, but it will take some time as i'm on a tight schedule now and can't write the article now. Let me know if you want the example. Fade (Amit BS)

        D Offline
        D Offline
        DK KiloDunse
        wrote on last edited by
        #3

        Thanks for the reply. Any help would be great. You can send it too kim@web-tech.dk. :) Hubbi

        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