Results 1 to 6 of 6
- 12-11-2008, 08:05 PM #1
Member
- Join Date
- Dec 2008
- Posts
- 2
- Rep Power
- 0
- 12-11-2008, 08:28 PM #2
Why are you using UDP?
Moving a file is exactly why TCP was invented.
If you use UDP, you have to implement all the error correction and out of order stuff yourself.
- 12-12-2008, 05:06 AM #3
Senior Member
- Join Date
- Nov 2008
- Posts
- 286
- Rep Power
- 5
Essentially, you have to "manage it". That's the thing about UDP.
I think you have a couple of options. The first is, just have a single DatagramSocket object. This could be a simple option if the result of every received datagram is to immediately send out a corresponding packet. Obviously, you check the packet to see which client send the request, and send back a packet to that client.
Java also supports the pretend notion of "connecting" datagram sockets to a client (i.e. limiting a DatagramSocket object to sending/receiving from a particular client). So you could have a DatagramSocket object per client that you send to, and use a traditional server model of having worker threads that send the data back. This would be a better option if the server needs to "think" a little after receiving each request before sending back the response.Neil Coffey
Javamex - Java tutorials and performance info
- 12-12-2008, 07:52 PM #4
Member
- Join Date
- Dec 2008
- Posts
- 2
- Rep Power
- 0
thanks for your relpy. i create a loop which receive a connection from once client, then i create a thread to transfer file to that client while the loop go back to listen other connection.
but the problem is when i create a thread, program said that "address is used", but which my knowledge,a UDPserver can communicate with many clients at the same socket. please help me!!
- 12-12-2008, 08:00 PM #5
Senior Member
- Join Date
- Nov 2008
- Posts
- 286
- Rep Power
- 5
I wonder if you could post appropriate snippets of your code, with the exact line where you're getting "address is used" (plus the actual, verbatim error).
Neil Coffey
Javamex - Java tutorials and performance info
- 12-12-2008, 08:56 PM #6
Member
- Join Date
- Dec 2008
- Posts
- 1
- Rep Power
- 0
Similar Threads
-
how to connect a server to multiple clients?
By azhar in forum NetworkingReplies: 15Last Post: 03-22-2010, 12:54 PM -
Multi Client/Server Chat Question
By Kodak07 in forum NetworkingReplies: 3Last Post: 03-29-2009, 10:50 PM -
SSL Server with authentication of clients
By zoltan in forum NetworkingReplies: 0Last Post: 10-14-2008, 11:27 PM -
blocked between server and clients
By ibtehal in forum NetworkingReplies: 6Last Post: 07-17-2008, 12:30 AM -
A generic framework for a flexible, multi-threaded server
By Java Tip in forum java.netReplies: 0Last Post: 04-07-2008, 08:14 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks