1 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 group_addr=null; 16 17 public TcpHeader() { 18 } 20 public TcpHeader(String n) { 21 group_addr=n; 22 } 23 24 public String 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 { 34 group_addr=(String )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 , InstantiationException { 42 group_addr=in.readUTF(); 43 } 44 45 public long size() { 46 return group_addr.length() +2; 47 } 48 } 49 | Popular Tags |