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?

836981 wrote:
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 receive a connection when someone wants to send a file to them)Read up on peer-to-peer.
and I will also have a socket object that will connect to a client when I want to send a file to them.A new socket for each outbound connection.
Is it possible to run all these connections on a single port?Yes. A serversocket listens for connections to a specific port number, it can accept many connections.
Or will there be a conflict?No. Your outbound connections will not use the same port number locally.
You are more likely to encounter problems with clients (peers) behind NAT routers.

Similar Messages

  • Two server sockets on the same machine, one not working.

    Dear forum users.
    I'm currently having a problem with running two server sockets on the same computer.
    It gives no exceptions or anything, just that if i connect with another machine, the last serversocket that started,
    will not accept connections..
    Scenario:
    Computer 1: Main server.
    Computer 1: Game server.
    Computer 2: Client
    Computer 2 connects first to the main server (lets say port 13371)
    Then connects to game server (port 6112).
    Computer 2 failes to connect to the Game server for some reason.
    But if i open a client at Computer 1, connects to main server, and then game server, it
    works fine.
    And if I put computer 2 as a Game server,
    then everything works fine.
    Working scenario:
    Computer 1: Main server.
    Computer 2: Game server
    Computer 2: Client
    Computer 1: Client
    Now, however many that wants to connect to game server, works.
    I have gone through the code 100 times now it feels like. And still dont see why this happends.
    Anyone know if it is "working as intended"? Or just me doing something completely wrong that i cant see myself?
    Sorry for not posting code, its too much code to post.

    Oh, sorry.
    TCPServer:
    protected ServerSocket serverSocket;
    public abstract void processConnection(Socket client);
        public void listen() {
            try {
                report("Listening to clients on port: " + portNumber);
                while (serverSocket != null && acceptConnections) {
                    processConnection(serverSocket.accept());
                    report("Client accepted on serverSocket.");
            } catch (SocketException e) {
                report("TCPServer/listenForClients : SocketException.", e);
            } catch (Exception e) {
                report("TCPServer/listenForClients : Unknown Exception.", e);
            cleanUp();
            report("Stopped listening on port: " + portNumber);
        }MainServer extends the TCPServer:
        public void processConnection(Socket client) {
            try {
                MainServer_Client tmp = new MainServer_Client(client, this);
                synchronized (clients) {
                    clients.add(tmp);
                Thread th = new Thread(tmp);
                th.start();
            } catch (Exception e) {
                report("MainServer/processConnection : Unknown Exception", e);
        }GameServer extends TCPServer
        public void processConnection(Socket client) {
            try {
                client.setTcpNoDelay(true);
                GameServer_ServerClient tmp = new GameServer_ServerClient(client, this);
                synchronized(clients) {
                    clients.add(tmp);
                Thread th = new Thread(tmp);
                th.start();
            } catch(Exception e) {
                report("GameServer_Host/processConnection : Unknown Exception",e);
                e.printStackTrace();
        }Edited by: Lgeee on Apr 30, 2010 2:57 AM

  • I have an iCloud email address on my iMac. How can I create an icloud email address for my wife on the same computer?

    I have an iCloud email address on my iMac. How can I create an icloud email address for my wife on the same computer?

    If all you want is an additional email address you can create up to three 'email aliases'  - these are additional addresses (not accounts) which deliver into the same inbox as the main account.
    You should be aware before you start that once you've created an alias you cannot turn that address into a full iCloud account, move it to another account, or reactivate it if you delete it.
    More information on aliases here:
    http://help.apple.com/icloud/#mm6b1a490a
    If you want to keep her email separate from yours she will need to create a new Apple ID, and use it to create a new iCloud account either on a separate computer or on a separate User Account on your Mac.

  • Getting error in my device while signing up to ICloud. The same ID's is working well in downloading itunes

    Getting error in my device while signing up to ICloud. The same ID's is working well in downloading itunes

    Hi Maninder Singh Golar,
    Thanks for visiting Apple Support Communities.
    If you can use your Apple ID to sign into the iTunes Store, but not iCloud, see this article for some troubleshooting tips that can help:
    iCloud: Account troubleshooting
    http://support.apple.com/kb/TS3988
    Cheers,
    Jeremy

  • Two applications wants to read on the same port using Socket

    I have an application running on one machine using TCP/IP socket. The data transfer with the other application on other machine is in ASCII.
    Now I want a new application that can have a copy of data received and sent on the given port, where the previous application is running.
    Is it possible in Java using socket and TCP/IP to have two application reading data from the same port and both can read all the data.

    Even when you don't state the type of app which need to read the data stream (is it a server or a client app???), it's impossible to share a single TCP/IP socket among multiple apps.
    Perhaps the best thing to do is to develop something like a proxy server who listens on the nominated port and provides to contact (if your apps are server ones) or to be contacted (if your apps are client ones) by the desired apps.
    This way, the only job for the proxy is to duplicate the contents of the data stream and make them available to all the apps engaged.
    Hope this helps.

  • Why can't I buy any app ? Iv tried creating a new Appel account ect but it says the same thing everytime . Sorry your payment was declined . How can I sort this ? Please help

    Why can't I buy any app ? Iv tried creating a new Appel account ect but it says the same thing everytime . Sorry your payment was declined . How can I sort this ? Please help

    - Try another payment method.
    - Contact iTunes
    Apple - Support - iTunes - Contact Us
    - Create a NEW account using these instructions. Make sure you follow the instructions. Many do not and if you do not you will not get the None option. You must use an email address that you have not used with Apple before.
    Creating an iTunes Store, App Store, iBookstore, and Mac App Store account without a credit card

  • I cannot open numbers.  When I double click on the icon it says "Numbers cannot be opened while it is being updated."  The same is happening with other programs.  I recently upgraded to Mavericks

    I cannot open numbers.  When I double click on the icon it says "Numbers cannot be opened while it is being updated."  The same is happening with other programs.  I recently upgraded to Mavericks

    Well, I figured itout.
    Apparently the Numbers (and Pages) app downloads was stopped and \never re\started.. possibly because of something I did, like turn off my machine during them.
    I went to Apple > App Store > Purchases.  I discovered all three iWorks apps were listed but showed "Resume" as the status button at the right.  I clicked on each to get them started again... and they eventually automatically became "Installed".
    They work, now!

  • Open Ports of Sockets at the Same Time

    Is it any possible I can write a code for open different number of ports for sockets at the same time??
    I try to use thread but it is not work....

    You want to know if you can open more than one socket where each socket uses a different port?
    Yes, you can.

  • How you create a group to send many txt msg at the same time?

    How you create a group to send many txt msg at the same time?

    The iPhone does not support groups for messaging. There are apps in the app store which purport to be able to do this.

  • How do you create aligned interactive text boxs in a PDF with the same width and height?

    how do you create aligned interactive text boxs in a PDF with the same width and height?
    Without free hand creating the sizing?

    Assuming by "interactive text boxes" you mean form fields; in Acrobat, make a form field, then copy it and paste. (GIve the pasted copy a different name so they don't genetate the same field feedback.) Now you have two fields of the exact same size. Shift-click or marquee-drag to select both, then right-click and choose a command from the Align, Distribute or Center menu.

  • WebI:Creating a minus query from data providers not using the same universe

    Hi there. A client of ours wishes to use Combined Query on multiple universes in the same WebI report. So far, I have heard it is not feasible in WebI. I know it is possible in DeskI. Even the sub-query option is limited to just one universe in WebI. So, I am stuck.
    Is there a workaround to creating a minus query from data providers not using the same universe in WebI?

    Hello Amit,
    what are the Datasources ? Usually when you create a Sub Query you can choose a seperate Universe.
    Maybe if you only see one Universe you only have the rights for this Universe ?!.
    Regards
    -Seb.

  • How to handle when Client and server write to the socket at the same time

    Hi all,
    I'm writing a socket communication when client and server may write information the the socket at the same time. I look every where but the samples from the internet only shows example of server replies to client after receiving requests from clients.
    Let's say that:
    Client 1 ->Socket 1 -> Server 1
    Now if there are two threads in the server, one blocked waiting for the input from client on socket 1, the second one write something on the socket to client 1, is it possible?
    And if it's possible, if at the time Server 1 writes information to Client 1, Client 1 writes some information to Server 1 too, will there be any conflict problem or the socket could handle that two ways communication simultaneously?
    It's critical questions for me. Thanks for your help.

    I really use Server Client paradigm. However, beside the request, response mechanism, there is also an additional mechanism called update which server periodically send information update to client without the need for a request from client.
    So you suggest client should initiate 2 sockets, one for request and response, one for receiving update from the server? Will this work?

  • Can I load batteries from an electrical socket, using the same as my IPhone charger?

    Can I load batteries from an electrical socket, using the same as my IPhone charger?

    Your terminology is confusing...  If you are describing the USB power adapter (that plugs into a wall outlet) that you use to charge your iPhone, you can use the same connection to charge your iPod nano.

  • Two while loops working in parallel at the same time

    Hello, how can I run a .vi with two while loops working in parallel at the same time? . I want that when I run a vi both can be activated o desactivate, but I can't get it. What can I do?
    Thanks a lot.
    Luz

    Here are some links for state machines.
    http://zone.ni.com/devzone/conceptd.nsf/webmain/c7​4cec177a289dbd86256c4e00600196
    http://zone.ni.com/devzone/conceptd.nsf/webmain/8C​4EECACF084F8E986256802007B9186
    http://sine.ni.com/nips/cds/view/p/lang/en/nid/137​47
    http://sine.ni.com/apps/utf8/niepd_web_display.dis​play_epd4?p_guid=B45EACE3DE6756A4E034080020E74861
    http://sine.ni.com/apps/utf8/niepd_web_display.dis​play_epd4?p_guid=B45EACE3E1E956A4E034080020E74861

  • Listening to 2 UDP sockets at the same time

    I would like to know if it is possible to listen to two different UDP sockets at the same time without loss of any packets? If so, will the data be buffered ? How do we limit the buffer size on a Windows XP host?

    gprassad,
    You can use two parallel UDP Read functions working in a loop. Set a timeout to low value and clear the timeout error if it occures. Data transferred by UDP protocol is buffered by operating system and the user has no direct way to change it in LabVIEW.
    Arkadiusz Roszczewski
    National Instruments

Maybe you are looking for

  • Outgoing mail is not working on the Macbook Pro

    Hey I am using the mail client to read my gmail mails in my Macbook Pro. Incoming and outgoing emails were working fine and all of a sudden for the last 2 days my outgoing mails are not working and i get this error" the sender address blah blah.com w

  • Oracle error in ODI

    HI All, I am using ODI 11. I have a requirment where i need to see oracle error in ODI operator . Suppose the error is Format/Datatype/or etc error then it will show as the error with the error code in Operator. Plz let me know how to do this in ODI.

  • I would like to unlock my iphone 5

    i want a help from you. i would like to unlock my iphone 5

  • Help!  Pages is killing my files: multiple "index.pages" couldn't be opened error messages.*

    I have had 4 pages files in the last two weeks get corrupted and come up with the error messafe: "'index.pages' couldn't be opened.  The requried index.xml file is missing."  I have tried several ways to restore the file, but none work.  My bigger qu

  • Is Mavericks annoying to most people, or just for me?

    My finder window won't stay the size I want it to in column view.  Is it too much to ask to see my whole file name without the finder column "intuitively" shrinking back to it's skinny default size?  I resize the column, drag a file to a new location