0

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.

3
Contributors
2
Replies
4
Views
8 Years
Discussion Span
Last Post by neilcoffey
0

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:

while(true)
		   {
                       ServerSocket servSock = new ServerSocket(8888, 5);
		        Socket client = servSock.accept();
			 multiThread connection = new multiThread(client);
                         Thread t = new Thread(connection);
			 
                         t.start();
                         
                   }

private multiThread implements Runnable {

  void run() {
   ............
   ...........
  }

}

Albert

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.