xpg94
xpg94

Reputation: 513

Sending a linked list through socket in java

I want to send a linked list of objects through TCP socket from server to client, and vice-versa. How can I do that? Should I send just a head of linked list, or is there some other way?

Upvotes: 1

Views: 924

Answers (1)

T.Gounelle
T.Gounelle

Reputation: 6033

Use LinkedList<T> which is Serializable.

EDIT The T must implement the Serializable interface which has no method - This just a marker. Your class may have some fields that are not essential to the object (for instance, a cached value computed from actual properties of the object), these can be declared as transient.
Have a look at the doc of Serializable.

Upvotes: 3

Related Questions