Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to use two serverSocket in a single program

 
vinoth sathiyamoorthy
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,

I writing a program using two server sockets to listen two clients simultaneously but it should be connected to only one client of any one which makes the request first. In coding the first socket will be listen state and the second is not listening. At a time only one client can connected to server socket and other should not connected to the server socket(second). I attached the code for the sample for your consideration(It cannot accept two client request at a time.). It supports for the first client alone since the first clients accept is given first. I hava to listen both the clients and connect any one.


JCE: Please Use Code Tags
 
Joe Ess
Bartender
Posts: 9362
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A Socket instance will never be equal to a String:

 
vinoth sathiyamoorthy
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Problem in two servers listening in single program.
only else part execute(accepted) if condition is not accept.how to execute simultaneous?
if condition will execute then execute else part. but in my program does not execute two(both if and else).
please help me....
 
Joe Ess
Bartender
Posts: 9362
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I told you. Your if condition is wrong.
Perhaps this article will clear up how to work with sockets. If you want to allow more than one client to connect, you do not need to create more than one ServerSocket.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!