943,694 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 4391
  • Java RSS
Dec 11th, 2008
0

multiple clients conect to UDP server

Expand Post »
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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
bachma7 is offline Offline
2 posts
since Dec 2008
Dec 15th, 2008
0

Re: multiple clients conect to UDP server

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:
java Syntax (Toggle Plain Text)
  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
Reputation Points: 9
Solved Threads: 2
Light Poster
AlbertPi is offline Offline
33 posts
since Nov 2008
Dec 16th, 2008
0

Re: multiple clients conect to UDP server

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.
Reputation Points: 120
Solved Threads: 7
Junior Poster in Training
neilcoffey is offline Offline
53 posts
since Dec 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Urgent Binary Search Tree
Next Thread in Java Forum Timeline: Please help





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC