sending dataset from udp/socket

A

alpergroups

Hello Folks,

I'm working' on socket connections/udp right now.
But i have one question in my mind. How can i send querydataset over
socket?
will i send it like a byte and cast it to the dataset? or what?
 
F

frankgerlach22

If both ends of the communication channel are written in Java, Java
Serialization would be the way to go. If not, then a self-written
Serialization framework would do the job. Note that in many cases RMI,
EJB or CORBA will be appropriate. It may not be worth the effort to
reinvent the wheel...
 
J

John C. Bollinger

I'm working' on socket connections/udp right now.
But i have one question in my mind. How can i send querydataset over
socket?
will i send it like a byte and cast it to the dataset? or what?

You need a means to encode your dataset object as a sequence of bytes,
and another to decode the bytes and reconstitute the dataset on the
other side. Java sports a built-in mechanism to do this, called
serialization. Make your dataset class Serializable (which may be as
simple as just making it implement that interface, but which could be
significantly more complicated), then use ObjectOutputStreams and
ObjectInputStreams to send and receive instances, respectively.

You could also handle the whole thing yourself via some
application-level protocol. Do note, by the way, that UDP is not a
reliable protocol (meaning that it does not guarantee message delivery,
nor delivery order for those messages that are delivered). If that
matters to you then you should probably be using TCP.


John Bollinger
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top