Results 1 to 3 of 3
  1. #1
    Vortexnl is offline Member
    Join Date
    Feb 2011
    Posts
    8
    Rep Power
    0

    Default Creating a serverSocket while sonnecting to a socket on the same port

    I want to make a file transfer application for multiple clients, there will not be a server that users will connect to, the application serves as client AND server, every client will have a serversocket object listen for new connections (it will recieve a connection when someone wants to send a file to them) and I will also have a socket object that will connect to a client when I want to send a file to them.

    Is it possible to run all these connections on a single port? Or will there be a conflict?

  2. #2
    glauber is offline Member
    Join Date
    Feb 2011
    Location
    So Jos dos Campos, Brazil
    Posts
    6
    Rep Power
    0

    Default

    Only one server can connect to a port at a given time. If the port is already in use, the server socket won't be able to bind to it. However, multi-threaded servers are able to serve multiple clients at the same time.

  3. #3
    toadaly is offline Senior Member
    Join Date
    Jan 2009
    Posts
    671
    Rep Power
    6

    Default

    For a given IP, only one ServerSocket per port is allowed. If your host has multiple IPs associated with different network interfaces, then you can also use the same port number for those different interfaces (OS dependent). If your application is running with 1 copy per host, then you can use the same port number (assuming it's available) on all hosts since they all have different IPs.

    What you can't do is have 2 ServerSockets trying to use the same port on the same IP.

Similar Threads

  1. Replies: 1
    Last Post: 01-17-2010, 03:29 PM
  2. Creating Socket
    By ersachinjain in forum Networking
    Replies: 1
    Last Post: 11-18-2009, 10:10 PM
  3. Client Socket Fails to Connect to ServerSocket
    By Sir_Fz in forum Networking
    Replies: 4
    Last Post: 11-03-2009, 07:44 AM
  4. Creating Socket Issue
    By castiel in forum Networking
    Replies: 2
    Last Post: 08-25-2009, 01:34 PM
  5. Socket programming - port issues
    By ravian in forum Networking
    Replies: 2
    Last Post: 11-07-2007, 10:24 AM

Posting Permissions

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