Examples of SocketWrapper


Examples of org.apache.harmony.rmi.transport.SocketWrapper

                                    s.getPort(), s.getLocalPort() }));
        }

        // Direct socket must be wrapped to avoid losing already read data.
        return (isHttp ? new HttpInboundSocket(s, in, null)
                       : new SocketWrapper(s, in, null));
    }
View Full Code Here

Examples of org.apache.harmony.rmi.transport.SocketWrapper

                                    s.getPort(), s.getLocalPort() }));
        }

        // Direct socket must be wrapped to avoid losing already read data.
        return (isHttp ? new HttpInboundSocket(s, in, null)
                       : new SocketWrapper(s, in, null));
    }
View Full Code Here

Examples of org.chromium.sdk.internal.transport.SocketWrapper

    if (loggerFactory == null) {
      browserConnectionLogger = null;
    } else {
      browserConnectionLogger = loggerFactory.newBrowserConnectionLogger();
    }
    final SocketWrapper socketWrapper = new SocketWrapper(
        socketAddress, DEFAULT_CONNECTION_TIMEOUT_MS, browserConnectionLogger,
        HandshakeUtil.ASCII_CHARSET);
    try {
      if (browserConnectionLogger != null) {
        browserConnectionLogger.start();
        browserConnectionLogger.setConnectionCloser(new ConnectionLogger.ConnectionCloser() {
          @Override
          public void closeConnection() {
            socketWrapper.getShutdownRelay().sendSignal(null, new Exception("UI close request"));
          }
        });
      }
      LoggableOutputStream output = socketWrapper.getLoggableOutput();
      writeHttpLine(output, "GET " + resource + " HTTP/1.1");
      writeHttpLine(output, "User-Agent: ChromeDevTools for Java SDK");
      writeHttpLine(output, "Host: " + socketAddress.getHostName() + ":" +
          socketAddress.getPort());
      writeHttpLine(output, "");
      output.getOutputStream().flush();

      LoggableInputStream input = socketWrapper.getLoggableInput();

      HandshakeUtil.HttpResponse httpResponse =
          HandshakeUtil.readHttpResponse(HandshakeUtil.createLineReader(input.getInputStream()));

      if (httpResponse.getCode() != 200) {
        throw new IOException("Unrecognized respose: " + httpResponse.getCode() + " " +
            httpResponse.getReasonPhrase());
      }

      String lengthStr = httpResponse.getFields().get("content-length");
      if (lengthStr == null) {
        throw new IOException("Unrecognizable respose: no content-length");
      }
      int length;
      try {
        length = Integer.parseInt(lengthStr.trim());
      } catch (NumberFormatException e) {
        throw new IOException("Unrecognizable respose: incorrect content-length");
      }
      byte[] responseBytes = new byte[length];
      {
        int readSoFar = 0;
        while (readSoFar < length) {
          int res = input.getInputStream().read(responseBytes, readSoFar, length - readSoFar);
          if (res == -1) {
            throw new IOException("Unexpected EOS");
          }
          readSoFar += res;
        }
      }
      return new String(responseBytes, HandshakeUtil.UTF_8_CHARSET);
    } finally {
      if (browserConnectionLogger != null) {
        browserConnectionLogger.handleEos();
      }
      socketWrapper.getShutdownRelay().sendSignal(null, null);
    }
  }
View Full Code Here

Examples of org.chromium.sdk.internal.transport.SocketWrapper

    if (loggerFactory == null) {
      browserConnectionLogger = null;
    } else {
      browserConnectionLogger = loggerFactory.newBrowserConnectionLogger();
    }
    final SocketWrapper socketWrapper = new SocketWrapper(
        socketAddress, DEFAULT_CONNECTION_TIMEOUT_MS, browserConnectionLogger,
        HandshakeUtil.ASCII_CHARSET);
    try {
      if (browserConnectionLogger != null) {
        browserConnectionLogger.start();
        browserConnectionLogger.setConnectionCloser(new ConnectionLogger.ConnectionCloser() {
          @Override
          public void closeConnection() {
            socketWrapper.getShutdownRelay().sendSignal(null, new Exception("UI close request"));
          }
        });
      }
      LoggableOutputStream output = socketWrapper.getLoggableOutput();
      writeHttpLine(output, "GET " + resource + " HTTP/1.1");
      writeHttpLine(output, "User-Agent: ChromeDevTools for Java SDK");
      writeHttpLine(output, "Host: " + socketAddress.getHostName() + ":" +
          socketAddress.getPort());
      writeHttpLine(output, "");
      output.getOutputStream().flush();

      LoggableInputStream input = socketWrapper.getLoggableInput();

      HandshakeUtil.HttpResponse httpResponse =
          HandshakeUtil.readHttpResponse(HandshakeUtil.createLineReader(input.getInputStream()));

      if (httpResponse.getCode() != 200) {
        throw new IOException("Unrecognized respose: " + httpResponse.getCode() + " " +
            httpResponse.getReasonPhrase());
      }

      String lengthStr = httpResponse.getFields().get("content-length");
      if (lengthStr == null) {
        throw new IOException("Unrecognizable respose: no content-length");
      }
      int length;
      try {
        length = Integer.parseInt(lengthStr.trim());
      } catch (NumberFormatException e) {
        throw new IOException("Unrecognizable respose: incorrect content-length");
      }
      byte[] responseBytes = new byte[length];
      {
        int readSoFar = 0;
        while (readSoFar < length) {
          int res = input.getInputStream().read(responseBytes, readSoFar, length - readSoFar);
          if (res == -1) {
            throw new IOException("Unexpected EOS");
          }
          readSoFar += res;
        }
      }
      return new String(responseBytes, HandshakeUtil.UTF_8_CHARSET);
    } finally {
      if (browserConnectionLogger != null) {
        browserConnectionLogger.handleEos();
      }
      socketWrapper.getShutdownRelay().sendSignal(null, null);
    }
  }
View Full Code Here

Examples of org.chromium.sdk.internal.transport.SocketWrapper

  }

  private String readHttpResponseContent(InetSocketAddress socketAddress, String resource,
      LoggerFactory loggerFactory) throws IOException {
    ConnectionLogger browserConnectionLogger = loggerFactory.newBrowserConnectionLogger();
    final SocketWrapper socketWrapper = new SocketWrapper(
        socketAddress, DEFAULT_CONNECTION_TIMEOUT_MS, browserConnectionLogger,
        HandshakeUtil.ASCII_CHARSET);
    try {
      if (browserConnectionLogger != null) {
        browserConnectionLogger.start();
        browserConnectionLogger.setConnectionCloser(new ConnectionLogger.ConnectionCloser() {
          @Override
          public void closeConnection() {
            socketWrapper.getShutdownRelay().sendSignal(null, new Exception("UI close request"));
          }
        });
      }
      LoggableOutputStream output = socketWrapper.getLoggableOutput();
      writeHttpLine(output, "GET " + resource + " HTTP/1.1");
      writeHttpLine(output, "User-Agent: ChromeDevTools for Java SDK");
      writeHttpLine(output, "Host: " + socketAddress.getHostName() + ":" +
          socketAddress.getPort());
      writeHttpLine(output, "");
      output.getOutputStream().flush();

      LoggableInputStream input = socketWrapper.getLoggableInput();

      HandshakeUtil.HttpResponse httpResponse =
          HandshakeUtil.readHttpResponse(HandshakeUtil.createLineReader(input.getInputStream()));

      if (httpResponse.getCode() != 200) {
        throw new IOException("Unrecognized respose: " + httpResponse.getCode() + " " +
            httpResponse.getReasonPhrase());
      }

      String lengthStr = httpResponse.getFields().get("content-length");
      if (lengthStr == null) {
        throw new IOException("Unrecognizable respose: no content-length");
      }
      int length;
      try {
        length = Integer.parseInt(lengthStr.trim());
      } catch (NumberFormatException e) {
        throw new IOException("Unrecognizable respose: incorrect content-length");
      }
      byte[] responseBytes = new byte[length];
      {
        int readSoFar = 0;
        while (readSoFar < length) {
          int res = input.getInputStream().read(responseBytes, readSoFar, length - readSoFar);
          if (res == -1) {
            throw new IOException("Unexpected EOS");
          }
          readSoFar += res;
        }
      }
      return new String(responseBytes, HandshakeUtil.UTF_8_CHARSET);
    } finally {
      if (browserConnectionLogger != null) {
        browserConnectionLogger.handleEos();
      }
      socketWrapper.getShutdownRelay().sendSignal(null, null);
    }
  }
View Full Code Here

Examples of org.chromium.sdk.internal.transport.SocketWrapper

  }

  private String readHttpResponseContent(InetSocketAddress socketAddress, String resource,
      LoggerFactory loggerFactory) throws IOException {
    ConnectionLogger browserConnectionLogger = loggerFactory.newBrowserConnectionLogger();
    final SocketWrapper socketWrapper = new SocketWrapper(
        socketAddress, DEFAULT_CONNECTION_TIMEOUT_MS, browserConnectionLogger,
        HandshakeUtil.ASCII_CHARSET);
    try {
      if (browserConnectionLogger != null) {
        browserConnectionLogger.start();
        browserConnectionLogger.setConnectionCloser(new ConnectionLogger.ConnectionCloser() {
          @Override
          public void closeConnection() {
            socketWrapper.getShutdownRelay().sendSignal(null, new Exception("UI close request"));
          }
        });
      }
      LoggableOutputStream output = socketWrapper.getLoggableOutput();
      writeHttpLine(output, "GET " + resource + " HTTP/1.1");
      writeHttpLine(output, "User-Agent: ChromeDevTools for Java SDK");
      writeHttpLine(output, "Host: " + socketAddress.getHostName() + ":" +
          socketAddress.getPort());
      writeHttpLine(output, "");
      output.getOutputStream().flush();

      LoggableInputStream input = socketWrapper.getLoggableInput();

      HandshakeUtil.HttpResponse httpResponse =
          HandshakeUtil.readHttpResponse(HandshakeUtil.createLineReader(input.getInputStream()));

      if (httpResponse.getCode() != 200) {
        throw new IOException("Unrecognized respose: " + httpResponse.getCode() + " " +
            httpResponse.getReasonPhrase());
      }

      String lengthStr = httpResponse.getFields().get("content-length");
      if (lengthStr == null) {
        throw new IOException("Unrecognizable respose: no content-length");
      }
      int length;
      try {
        length = Integer.parseInt(lengthStr.trim());
      } catch (NumberFormatException e) {
        throw new IOException("Unrecognizable respose: incorrect content-length");
      }
      byte[] responseBytes = new byte[length];
      {
        int readSoFar = 0;
        while (readSoFar < length) {
          int res = input.getInputStream().read(responseBytes, readSoFar, length - readSoFar);
          if (res == -1) {
            throw new IOException("Unexpected EOS");
          }
          readSoFar += res;
        }
      }
      return new String(responseBytes, HandshakeUtil.UTF_8_CHARSET);
    } finally {
      if (browserConnectionLogger != null) {
        browserConnectionLogger.handleEos();
      }
      socketWrapper.getShutdownRelay().sendSignal(null, null);
    }
  }
View Full Code Here

Examples of org.chromium.sdk.internal.transport.SocketWrapper

  }

  private String readHttpResponseContent(InetSocketAddress socketAddress, String resource,
      LoggerFactory loggerFactory) throws IOException {
    ConnectionLogger browserConnectionLogger = loggerFactory.newBrowserConnectionLogger();
    final SocketWrapper socketWrapper = new SocketWrapper(
        socketAddress, DEFAULT_CONNECTION_TIMEOUT_MS, browserConnectionLogger,
        HandshakeUtil.ASCII_CHARSET);
    try {
      if (browserConnectionLogger != null) {
        browserConnectionLogger.start();
        browserConnectionLogger.setConnectionCloser(new ConnectionLogger.ConnectionCloser() {
          @Override
          public void closeConnection() {
            socketWrapper.getShutdownRelay().sendSignal(null, new Exception("UI close request"));
          }
        });
      }
      LoggableOutputStream output = socketWrapper.getLoggableOutput();
      writeHttpLine(output, "GET " + resource + " HTTP/1.1");
      writeHttpLine(output, "User-Agent: ChromeDevTools for Java SDK");
      writeHttpLine(output, "Host: " + socketAddress.getHostName() + ":" +
          socketAddress.getPort());
      writeHttpLine(output, "");
      output.getOutputStream().flush();

      LoggableInputStream input = socketWrapper.getLoggableInput();

      HandshakeUtil.HttpResponse httpResponse =
          HandshakeUtil.readHttpResponse(HandshakeUtil.createLineReader(input.getInputStream()));

      if (httpResponse.getCode() != 200) {
        throw new IOException("Unrecognized respose: " + httpResponse.getCode() + " " +
            httpResponse.getReasonPhrase());
      }

      String lengthStr = httpResponse.getFields().get("content-length");
      if (lengthStr == null) {
        throw new IOException("Unrecognizable respose: no content-length");
      }
      int length;
      try {
        length = Integer.parseInt(lengthStr.trim());
      } catch (NumberFormatException e) {
        throw new IOException("Unrecognizable respose: incorrect content-length");
      }
      byte[] responseBytes = new byte[length];
      {
        int readSoFar = 0;
        while (readSoFar < length) {
          int res = input.getInputStream().read(responseBytes, readSoFar, length - readSoFar);
          if (res == -1) {
            throw new IOException("Unexpected EOS");
          }
          readSoFar += res;
        }
      }
      return new String(responseBytes, HandshakeUtil.UTF_8_CHARSET);
    } finally {
      if (browserConnectionLogger != null) {
        browserConnectionLogger.handleEos();
      }
      socketWrapper.getShutdownRelay().sendSignal(null, null);
    }
  }
View Full Code Here

Examples of org.chromium.sdk.internal.transport.SocketWrapper

  }

  private String readHttpResponseContent(InetSocketAddress socketAddress, String resource,
      LoggerFactory loggerFactory) throws IOException {
    ConnectionLogger browserConnectionLogger = loggerFactory.newBrowserConnectionLogger();
    final SocketWrapper socketWrapper = new SocketWrapper(
        socketAddress, DEFAULT_CONNECTION_TIMEOUT_MS, browserConnectionLogger,
        HandshakeUtil.ASCII_CHARSET);
    try {
      if (browserConnectionLogger != null) {
        browserConnectionLogger.start();
        browserConnectionLogger.setConnectionCloser(new ConnectionLogger.ConnectionCloser() {
          @Override
          public void closeConnection() {
            socketWrapper.getShutdownRelay().sendSignal(null, new Exception("UI close request"));
          }
        });
      }
      LoggableOutputStream output = socketWrapper.getLoggableOutput();
      writeHttpLine(output, "GET " + resource + " HTTP/1.1");
      writeHttpLine(output, "User-Agent: ChromeDevTools for Java SDK");
      writeHttpLine(output, "Host: " + socketAddress.getHostName() + ":" +
          socketAddress.getPort());
      writeHttpLine(output, "");
      output.getOutputStream().flush();

      LoggableInputStream input = socketWrapper.getLoggableInput();

      HandshakeUtil.HttpResponse httpResponse =
          HandshakeUtil.readHttpResponse(HandshakeUtil.createLineReader(input.getInputStream()));

      if (httpResponse.getCode() != 200) {
        throw new IOException("Unrecognized respose: " + httpResponse.getCode() + " " +
            httpResponse.getReasonPhrase());
      }

      String lengthStr = httpResponse.getFields().get("content-length");
      if (lengthStr == null) {
        throw new IOException("Unrecognizable respose: no content-length");
      }
      int length;
      try {
        length = Integer.parseInt(lengthStr.trim());
      } catch (NumberFormatException e) {
        throw new IOException("Unrecognizable respose: incorrect content-length");
      }
      byte[] responseBytes = new byte[length];
      {
        int readSoFar = 0;
        while (readSoFar < length) {
          int res = input.getInputStream().read(responseBytes, readSoFar, length - readSoFar);
          if (res == -1) {
            throw new IOException("Unexpected EOS");
          }
          readSoFar += res;
        }
      }
      return new String(responseBytes, HandshakeUtil.UTF_8_CHARSET);
    } finally {
      if (browserConnectionLogger != null) {
        browserConnectionLogger.handleEos();
      }
      socketWrapper.getShutdownRelay().sendSignal(null, null);
    }
  }
View Full Code Here

Examples of org.chromium.sdk.internal.transport.SocketWrapper

public class Hybi00WsConnection
    extends AbstractWsConnection<LoggableInputStream, LoggableOutputStream> {

  public static Hybi00WsConnection connect(InetSocketAddress endpoint, int timeout,
      String resourceId, String origin, ConnectionLogger connectionLogger) throws IOException {
    SocketWrapper socketWrapper =
        new SocketWrapper(endpoint, timeout, connectionLogger, LOGGER_CHARSET);

    boolean handshakeDone = false;
    Exception handshakeException = null;
    try {
      Hybi00Handshake.performHandshake(socketWrapper, endpoint, resourceId, origin,
          HANDSHAKE_RANDOM);
      handshakeDone = true;
    } catch (RuntimeException e) {
      handshakeException = e;
      throw e;
    } catch (IOException e) {
      handshakeException = e;
      throw e;
    } finally {
      if (!handshakeDone) {
        socketWrapper.getShutdownRelay().sendSignal(null, handshakeException);
      }
    }

    return new Hybi00WsConnection(socketWrapper, connectionLogger);
  }
View Full Code Here

Examples of org.jboss.remoting.transport.socket.SocketWrapper

         if (isCallbackInvoker)
         {
            listenerIdToCallbackClientInvokerMap.remove(listenerId);
            for (Iterator it = pool.iterator(); it.hasNext();)
            {
               SocketWrapper socketWrapper = (SocketWrapper) it.next();
               try
               {
                  socketWrapper.close();
               }
               catch (Exception ignored)
               {
               }
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.