2 Clients, 1 Server in Java

I'm writing a card game, similar to poker which is for 2 people.  So I need 2 clients and 1 server program.  Is this possible without threads?  I find threads very difficult and would like to focus on getting it done.  What I am trying to do now is create 2 server sockets in my server program and then have one client connect to one of each of the server sockets.   That doesn't seem right though.  Help?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

In poker, as far as I know, the players are playing sequentially - so you probably can
 do it without threads.
Maybe it sounds a little crazy, but you can set up
RMI servers on both machines, and when one player
plays, it will call a method on another client's machine and
it will request the response from the second player
and vice versa.
You can maintain the data on the cards in database
accesible from both or on one of the RMI servers or pass
it together with the each move.
This is not scalable for more than 2 players, but will
work for just 2 players and RMI is easy to implement and is rather
lightweight. And I guess there is no reason why RMI
server should not be connected to visual front end.

Maybe your idea with sockets is more narural after all,
but then i guess, the client will need to poll the server
to know if the other player played, if we don't want to use
jpking72Author Commented:
how about node.js?
And what  is node.js?

I guess you can have it something as web server with javascript.

Java is closer to my mind though than web and javascript
Angular Fundamentals

Learn the fundamentals of Angular 2, a JavaScript framework for developing dynamic single page applications.

>>So I need 2 clients and 1 server program.  Is this possible without threads?  

Yes. Make the server run two ServerSocket instances on different ports. Each client will connect to its own port

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jpking72Author Commented:
Thanks CEHJ,

A follow-up question:

How do I dynamically determine if socket1 has been bound?

I was thinking something like:

//check if port 5000 is already connected:
connection = new Socket(InetAddress.getByName("localhost"), 5000);
connection = new Socket(InetAddress.getByName("localhost"), 5010);

>>How do I dynamically determine if socket1 has been bound?

Why would you do that?
jpking72Author Commented:
i have one client to connect to port 6000
and the other to connect to port 6010.  

Or do i just hard code it and make two different client files, one with 6000 and one with 6010
>>Or do i just hard code it and make two different client files, one with 6000 and one with 6010

You could,  yes
Mick BarryJava DeveloperCommented:
you only want one server socket. opening a server socket for every player is a bad idea and will just cause you problems in the long run
and it won't work without using threads anyway so is just going to waste your time
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.