| 135 | } |
| 136 | |
| 137 | @Override |
| 138 | public void writeTo(DataOutput out) throws IOException { |
| 139 | if(ip_addr != null) { |
| 140 | byte[] address=ip_addr.getAddress(); // 4 bytes (IPv4) or 16 bytes (IPv6) |
| 141 | out.writeByte(address.length); // 1 byte |
| 142 | out.write(address, 0, address.length); |
| 143 | if(ip_addr instanceof Inet6Address) |
| 144 | out.writeInt(((Inet6Address)ip_addr).getScopeId()); |
| 145 | } |
| 146 | else { |
| 147 | out.writeByte(0); |
| 148 | } |
| 149 | out.writeShort(port); |
| 150 | } |
| 151 | |
| 152 | @Override |
| 153 | public void readFrom(DataInput in) throws IOException { |