multiple clients conect to UDP server

Reply

Join Date: Dec 2008
Posts: 2
Reputation: bachma7 is an unknown quantity at this point 
Solved Threads: 0
bachma7 bachma7 is offline Offline
Newbie Poster

multiple clients conect to UDP server

 
0
  #1
Dec 11th, 2008
hi every body,i have a question- i programing UDP server to download file,it 's work but it can serve only one client one time, how could i create a udp server that can serve a lot clients at the same time. thank you very much.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 33
Reputation: AlbertPi is an unknown quantity at this point 
Solved Threads: 2
AlbertPi AlbertPi is offline Offline
Light Poster

Re: multiple clients conect to UDP server

 
0
  #2
Dec 15th, 2008
You need to code multi-thread in your UDP server side. I believe you google this you will find some good URLs.
In your UDP server:
You need:
  1. while(true)
  2. {
  3. ServerSocket servSock = new ServerSocket(8888, 5);
  4. Socket client = servSock.accept();
  5. multiThread connection = new multiThread(client);
  6. Thread t = new Thread(connection);
  7.  
  8. t.start();
  9.  
  10. }
  11.  
  12. private multiThread implements Runnable {
  13.  
  14. void run() {
  15. ............
  16. ...........
  17. }
  18.  
  19. }

Albert
Last edited by cscgal; Dec 15th, 2008 at 6:07 pm. Reason: Added code tags
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 53
Reputation: neilcoffey will become famous soon enough neilcoffey will become famous soon enough 
Solved Threads: 6
neilcoffey neilcoffey is offline Offline
Junior Poster in Training

Re: multiple clients conect to UDP server

 
0
  #3
Dec 16th, 2008
Erm.. of course that last example is TCP, not UDP...

@bachma7 -- if you're going to cross-post to multiple forums, please have the courtesy to tell people that that's what you're doing. In your previous post, I gave you some pointers and you mentioned you were getting an error and I asked if you could post some code and say precisely what the verbatim error message was and which line it was occurring on.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC