コード例 #1
0
  public PushProxyAcknowledgementVMsg(
      MsgHeader header, byte[] vendorId, int subSelector, int version, byte[] data)
      throws InvalidMessageException {
    super(header, vendorId, subSelector, version, data);
    if (version < VERSION) {
      throw new InvalidMessageException(
          "Vendor Message 'PushProxyAcknowledgement' with deprecated version: " + version);
    }
    if (version > VERSION) {
      throw new InvalidMessageException(
          "Vendor Message 'PushProxyAcknowledgement' with invalid version: " + version);
    }
    if (data.length != 6) {
      throw new InvalidMessageException(
          "Vendor Message 'PushProxyAcknowledgement' invalid data length: " + data.length);
    }

    byte[] ip = new byte[4];
    // the ip starts at byte 0
    ip[0] = data[0];
    ip[1] = data[1];
    ip[2] = data[2];
    ip[3] = data[3];

    int port = IOUtil.unsignedShort2Int(IOUtil.deserializeShortLE(data, 4));
    if (!AddressUtils.isPortInRange(port)) {
      throw new InvalidMessageException("Port out of range: " + port);
    }
    hostAddress = new DefaultDestAddress(ip, port);
  }
コード例 #2
0
ファイル: Connection.java プロジェクト: sbwhitecap/Phex-trunk
 public void disconnect() {
   NLogger.debug(Connection.class, "Disconnecting socket " + socket);
   IOUtil.closeQuietly(inputStream);
   IOUtil.closeQuietly(outputStream);
   IOUtil.closeQuietly(socket);
   inputStream = null;
   outputStream = null;
   socket = null;
 }
コード例 #3
0
 /** @param address */
 private static byte[] buildDataBody(DestAddress hostAddress) throws IllegalArgumentException {
   byte[] data = new byte[6];
   IpAddress ip = hostAddress.getIpAddress();
   if (ip == null) {
     throw new IllegalArgumentException(
         "Vendor Message 'PushProxyAcknowledgement' contains no IP.");
   }
   byte[] ipAddress = hostAddress.getIpAddress().getHostIP();
   data[0] = ipAddress[0];
   data[1] = ipAddress[1];
   data[2] = ipAddress[2];
   data[3] = ipAddress[3];
   IOUtil.serializeShortLE((short) hostAddress.getPort(), data, 4);
   return data;
 }