01: // $Id: TcpHeader.java,v 1.4 2005/04/15 13:17:02 belaban Exp $
02:
03: package org.jgroups.protocols;
04:
05: import org.jgroups.Header;
06: import org.jgroups.util.Streamable;
07:
08: import java.io.*;
09:
10: public class TcpHeader extends Header implements Streamable {
11: public String group_addr = null;
12:
13: public TcpHeader() {
14: } // used for externalization
15:
16: public TcpHeader(String n) {
17: group_addr = n;
18: }
19:
20: public String toString() {
21: return "[TCP:group_addr=" + group_addr + ']';
22: }
23:
24: public void writeExternal(ObjectOutput out) throws IOException {
25: out.writeObject(group_addr);
26: }
27:
28: public void readExternal(ObjectInput in) throws IOException,
29: ClassNotFoundException {
30: group_addr = (String) in.readObject();
31: }
32:
33: public void writeTo(DataOutputStream out) throws IOException {
34: out.writeUTF(group_addr);
35: }
36:
37: public void readFrom(DataInputStream in) throws IOException,
38: IllegalAccessException, InstantiationException {
39: group_addr = in.readUTF();
40: }
41:
42: public long size() {
43: return group_addr.length() + 2;
44: }
45: }
|