KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jgroups > protocols > TcpHeader


1 // $Id: TcpHeader.java,v 1.4 2005/04/15 13:17:02 belaban Exp $
2

3 package org.jgroups.protocols;
4
5
6 import org.jgroups.Header;
7 import org.jgroups.util.Streamable;
8
9 import java.io.*;
10
11
12
13
14 public class TcpHeader extends Header implements Streamable {
15     public String JavaDoc group_addr=null;
16
17     public TcpHeader() {
18     } // used for externalization
19

20     public TcpHeader(String JavaDoc n) {
21         group_addr=n;
22     }
23
24     public String JavaDoc toString() {
25         return "[TCP:group_addr=" + group_addr + ']';
26     }
27
28     public void writeExternal(ObjectOutput out) throws IOException {
29         out.writeObject(group_addr);
30     }
31
32
33     public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException JavaDoc {
34         group_addr=(String JavaDoc)in.readObject();
35     }
36
37     public void writeTo(DataOutputStream out) throws IOException {
38         out.writeUTF(group_addr);
39     }
40
41     public void readFrom(DataInputStream in) throws IOException, IllegalAccessException JavaDoc, InstantiationException JavaDoc {
42         group_addr=in.readUTF();
43     }
44
45     public long size() {
46         return group_addr.length() +2;
47     }
48 }
49
Popular Tags