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.


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

Results 1 to 2 of 2

Thread: Threads in multi client-server application

  1. #1
    Junior Member
    Join Date
    Apr 2011
    Thanked 0 Times in 0 Posts

    Default Threads in multi client-server application

    Hi guys,
    I'm developing an on-line poker game for my uni project and need some guidance.
    I have a server, which creates a new thread for each connected client. The server also hosts 3 tables and each client should be able to join any of them and play.So far I have something like this:

    Server starts and listens for incoming connections.
    Client connects and sends login details.
    Server starts thread(T1) for the client.
    T1 checks client's username and password.
    if(not ok) => client tries again.
    if(ok) => T1 continues to listen for client's input.

    ..and here I don't know what to do.Once connected the client should be able to browse the poker games and choose which one to join.So... do I need to use a separate thread on the client to maintain the connection to T1(see above) and then from that thread spawn another one which handles the poker game? Is it a good idea to have a thread start another one? Or do I start the thread, handling the table from the main client application process?

    I hope I make sense...If something is unclear, please let me know and I'll try to clarify it and post any code if necessary.
    Thank You
    PS: It's mostly about threads, so I thought it's better to post it here, not in networking

  2. #2
    Junior Member Mrc0d3r's Avatar
    Join Date
    Jun 2011
    TCP/IP Layer 3
    My Mood
    Thanked 6 Times in 5 Posts

    Default Re: Threads in multi client-server application

    Create a separate thread for each client who approaches the server, and you don't need to spawn another thread from it, rather handle the entire game through it.(which includes client's and server's mutual information exchange, modification of game data etc) Maintain all the connection instances in a hashtable sort of thing.

Similar Threads

  1. Client/Server
    By Dillz in forum Paid Java Projects
    Replies: 2
    Last Post: June 2nd, 2010, 05:19 AM
  2. Client Socket on Application Server
    By xevimaresma in forum Java Theory & Questions
    Replies: 0
    Last Post: April 12th, 2010, 07:00 AM
  3. Replies: 1
    Last Post: March 23rd, 2010, 02:29 AM
  4. Problems with client/server application
    By lori in forum AWT / Java Swing
    Replies: 3
    Last Post: January 15th, 2010, 01:12 PM
  5. RMI over SSL Client application
    By boilerchicken in forum Java Networking
    Replies: 0
    Last Post: November 10th, 2009, 07:52 AM