How would you structure this?

AFB

Lifer
Jan 10, 2004
10,718
3
0
I'm making a zero config p2p app for file transfers and chat using Java and UDP. Well, since I'm starting from scratch I need to implement my own discovery protocol which isn't hard , but it needs to flow on the network at the same time the data is getting transfered. Obvioulsy this is going to require quite a few threads, some of which will just block, but I see no way around it.

Option 1 - Seperate Discovery and App Data into differnet ports

You would have one thread listen on port f and another broadcast announcement packets also on port f. These would be seperate from the most of the program and would just be resposible for keeping the information of clients and expiring/updating them as required.

Then, there would be a second class that would listen on port p monitoring the incoming data and handling it as required whether that be buildign a file or what. Like above, there would also be a thread to transfer data from the client sending it over port p.


Option 2 -Integrate Discovery and App Data and use call backs to handle it

There would be only two threads that deal with the network. One to listen and call back the handler tha matches the header on the packet and oen to send out all the packets from the client. Threads could be used later to offload work from this and just store the data in a queue.



I hope that wasn't too ambiguous :). I'm open to questions/suggestions/other ideas.
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
I've got a question: what would possess you to create a file transfer protocol using udp?
 

AFB

Lifer
Jan 10, 2004
10,718
3
0
Originally posted by: kamper
I've got a question: what would possess you to create a file transfer protocol using udp?

I don't know. I'm fvcking bored and it gives me something to do. Yes, it would be hell checking all the data, but it would be fun :). I think I may just make a utility to share files via UDP as it would be less hassle. Useless ? Absolutly :D
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
Have you ever read about the internal details of tcp? And you want to try to reproduce some of that at an app level? You're nucking futs ;)

Obviously you'd have to reproduce reliability. You'd probably also want to do some form of congestion control because throwing the data out as fast as you can is just not a good situation. That's a pretty tall order.
 

Kilrsat

Golden Member
Jul 16, 2001
1,072
0
0
Originally posted by: kamper
Have you ever read about the internal details of tcp? And you want to try to reproduce some of that at an app level? You're nucking futs ;)

Obviously you'd have to reproduce reliability. You'd probably also want to do some form of congestion control because throwing the data out as fast as you can is just not a good situation. That's a pretty tall order.
There are actually some interesting papers published on reliable-udp, just have to look them up. This is pretty clearly just a learning project, so you might as well learn as much as possible. Experimentation with reliable-udp doesn't sound like a bad idea to me on a completely experimental protocol/client.

Example:
http://www.limewire.org/fishey...up/gnutella/udpconnect

That is an already implemented java reliable-UDP system.