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.

Recommended Answers

All 2 Replies

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.