Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: socket connection - moving from a single client to multiple clients

  1. #1
    Junior Member
    Join Date
    Dec 2013
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default socket connection - moving from a single client to multiple clients

    I have a socket connection: server - single client working fine

    I wish to add some extra clients

    Each client runs on a separate PC on the same network

    All PCs have a large similar java main program BUT the server PC is the only PC which initiates a trade

    When looking at examples on the net, most servers are closed after receiving a particular message from a client

    My clients send a single message to the server

    Supposedly I can put a counter in the server code and once it reaches the number of clients I have, I can close the server

    In the main java program on the server PC I come to a point in the code where I need to wait until all clients have sent their respective messages

    I am unsure how to do this or even if this is possible ?

    Am seeking a simple solution

    Bob M

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: socket connection - moving from a single client to multiple clients

    Normally the server starts a new thread for each client when it connects. The server should be able to handle several clients at the same time.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: socket connection - moving from a single client to multiple clients

    Also posted here: https://coderanch.com/t/711766/java/...-single-client

    http://www.javaprogrammingforums.com...s-posting.html
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Replies: 15
    Last Post: May 9th, 2014, 12:00 PM
  2. Replies: 0
    Last Post: May 8th, 2014, 02:38 PM
  3. UDP single vs multiple socket performance
    By ddeveloper89 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 8th, 2013, 09:50 AM
  4. Multiple clients and one server. How to send data from one client to the others
    By u-will-neva-no in forum Java Theory & Questions
    Replies: 1
    Last Post: March 21st, 2012, 07:29 PM