Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2006

Tip: Looking for answers? Try searching our database.

UDP, can't send Objects?

Thread view: 
StevensSpam@cfl.rr.com - 25 Apr 2006 04:07 GMT
Is true that UDP does not support passing objects directly like TCP
does? Please tell me I am missing something :O

I just got used to them in TCP, now I'm hooked. I have UDP code to
write and need my Objects!

Thanks!!
Roedy Green - 25 Apr 2006 04:38 GMT
>I just got used to them in TCP, now I'm hooked. I have UDP code to
>write and need my Objects!

you could use a Byte Array ObJect stream, then send the resulting
byte[].

Your objects had better not be attached to too much or they won't fit
in a packet.

see http://mindprod.com/applets/fileio.html
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Luc The Perverse - 25 Apr 2006 04:40 GMT
> Is true that UDP does not support passing objects directly like TCP
> does? Please tell me I am missing something :O
[quoted text clipped - 3 lines]
>
> Thanks!!

No because UDP cannot guarantee delivery.

Plus a TCP connection is like a stream - but UDP are just individual
packets.

However if you can serialize your class and make it smaller than a single
packet you shouldn't have trouble just inserting the info into a UDP packet
and sending away.

--
LTP

:)
PMA - 25 Apr 2006 05:57 GMT
StevensSpam@cfl.rr.com a écrit :

> Is true that UDP does not support passing objects directly like TCP
> does? Please tell me I am missing something :O
[quoted text clipped - 3 lines]
>
> Thanks!!

Hi,

The MAIN difference between TCP and UDP is that UDP DOES NOT insure you
that received packets are in the proper order. If you want to use UDP
to send objects, you can BUT you must do the following on server-side :
    a) Break your byte array to 512 bytes chunks for example
    b) Add a header to each packet giving the sequence number (the
ordinal number of the packet) and the global number of packet
    c) Add some code to acknwoledge each packet*
and on the client side :
    a) Re-assemble all that data that may have come not in the right
order, once all packets have arrived
    b) Aknwoledge all incoming packets

A good example inh the TFTP protocol (you can find an implementation in
jakarta Commons-Net project).

Regards
Roedy Green - 25 Apr 2006 06:14 GMT
>    a) Break your byte array to 512 bytes chunks for example
>     b) Add a header to each packet giving the sequence number (the
[quoted text clipped - 4 lines]
>order, once all packets have arrived
>     b) Aknwoledge all incoming packets

in other words, reinvent most of the TCP/IP wheel.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

PMA - 25 Apr 2006 18:58 GMT
In a way, yes ...
BUT
There might be technical needs for using UDP ... And when the network
is simple between two machines it might be interresting for simplicity
sake (this avoid too much protocol overhead).
Luc The Perverse - 26 Apr 2006 03:31 GMT
> In a way, yes ...
> BUT
> There might be technical needs for using UDP ... And when the network
> is simple between two machines it might be interresting for simplicity
> sake (this avoid too much protocol overhead).

Please quote the person you are replying to.   It takes at minimum about 15
extra seconds, to display read messages, find the previous message, read it,
then come back to your message and reread it.   In this case I hit the wrong
button, lost the message and then had to search for it.  EEK!

Yes - UDP is more efficient, but it is rarely simpler.

--
LTP

:)
Gordon Beaton - 26 Apr 2006 17:24 GMT
> Yes - UDP is more efficient, but it is rarely simpler.

For message based protocols where it doesn't matter if an occasional
message is lost (and there are many examples where this is true) UDP
is much simpler than TCP.

/gordon

Signature

[  do not email me copies of your followups  ]
g o r d o n + n e w s @  b a l d e r 1 3 . s e

Luc The Perverse - 26 Apr 2006 22:53 GMT
>> Yes - UDP is more efficient, but it is rarely simpler.
>
> For message based protocols where it doesn't matter if an occasional
> message is lost (and there are many examples where this is true) UDP
> is much simpler than TCP.

Thanks for the clarification.  I was considering tacking something like that
on the end

--
LTP

:)
PMA - 27 Apr 2006 18:54 GMT
>Please quote the person you are replying to.   It takes at minimum about 15
>extra seconds, to display read messages, find the previous message, read it,
>then come back to your message and reread it.   In this case I hit the wrong
>button, lost the message and then had to search for it.  EEK!
>
>Yes - UDP is more efficient, but it is rarely simpler.

Ooops ...
Sorry
Luc The Perverse - 27 Apr 2006 22:07 GMT
> >Please quote the person you are replying to.   It takes at minimum about
> >15
[quoted text clipped - 8 lines]
> Ooops ...
> Sorry

No problem

--
LTP

:)
Thomas Weidenfeller - 25 Apr 2006 07:41 GMT
> Is true that UDP does not support passing objects directly like TCP
> does? Please tell me I am missing something :O

TCP also does not support passing objects.

Both are transport protocols for octets. TCP connection/oriented, UDP
connection-less. Both don't care about objects. What is it what you
really want?

/Thomas
Signature

The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.