Package java.net

Examples of java.net.Socket$SocketOutputStream


    public SessionRemote(ConnectionInfo ci) {
        this.connectionInfo = ci;
    }

    private Transfer initTransfer(ConnectionInfo ci, String db, String server) throws IOException {
        Socket socket = NetUtils.createSocket(server, Constants.DEFAULT_TCP_PORT, ci.isSSL());
        Transfer trans = new Transfer(this);
        trans.setSocket(socket);
        trans.setSSL(ci.isSSL());
        trans.init();
        trans.writeInt(Constants.TCP_PROTOCOL_VERSION_6);
View Full Code Here


      exc.printStackTrace();
    }
  }

  public StompTest() throws Exception {
    socket = new Socket(host, port);
    inputBuffer = new ByteArrayOutputStream();
  }
View Full Code Here

  }

  public void testConnect() throws Exception {
    inputBuffer = new ByteArrayOutputStream();

    socket = new Socket(host, port);
    System.out.println("Open connection to localhost:" + port);

    String connect = "CONNECT\n" +
      "login: " + login + "\n" + "passcode: " + passcode + "\n" +
      "request-id: 1\n" + "\n" + STOMP_NULL;
View Full Code Here

    console("[" + new Date() + "] TJWS httpd " + hostName + " - "
        + acceptor + " is listening.");
    try {
      while (running) {
        try {
          Socket socket = acceptor.accept();
          // TODO consider to use ServeConnection object pool
          // TODO consider req/resp objects pooling
          keepAliveCleaner.addConnection(new ServeConnection(socket,
              this));
        } catch (IOException e) {
View Full Code Here


    public void run() {
        while(srv_sock != null && !srv_sock.isClosed()) {
            try {
                final Socket sock=srv_sock.accept();
                sockets.add(sock);

                createInterpreter();

                new Thread() {
                    public void run() {
                        try {
                            InputStream input=sock.getInputStream();
                            OutputStream out=sock.getOutputStream();
                            BufferedReader reader=new BufferedReader(new InputStreamReader(input));

                            while(!sock.isClosed()) {
                                String line=reader.readLine();
                                if(line == null || line.length() == 0)
                                    continue;
                                try {
                                    Object retval=interpreter.eval(line);
View Full Code Here

        Response response = new Response();

        response.server = server;
        response.port = port;

        Socket connection = AsyncSocketFactory.createSocket(server, port, timeout);
        try {
            PrintStream out = new PrintStream(connection.getOutputStream());
            try {
                BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
                try {
                    out.println(query);
                    StringBuffer sb = new StringBuffer();

                    String line;
                    while ((line = in.readLine()) != null) {
                        sb.append(line).append(lineSeparator);
                        line = line.trim();
                        if (! line.startsWith("%") && ! line.startsWith("#")) {
                            int fs = line.indexOf(":");
                            if (fs > 0) {
                                String name = line.substring(0, fs);
                                String value = line.substring(fs + 1).trim();
                                response.data.put(name, value);
                            }
                        }
                    }
                    response.summary = sb.toString();

                    Response newResponse = null;
                    String referral = (String) response.getData().get("ReferralServer");

                    if (referral != null) {
                        try {
                            URLParser url = new URLParser(referral);
                            if ("whois".equals(url.getProtocol())) {
                                newResponse = lookup(url.getHost(), url.getPort() == -1 ? 43 : url.getPort(), query,
                                        timeout, lineSeparator);
                            }
                        } catch (IOException e) {
                            System.out.println("Could not contact " + referral);
                        }
                    }
                    if (newResponse != null) {
                        response = newResponse;
                    }
                } finally {
                    in.close();
                }
            } finally {
                out.close();
            }
        } finally {
            connection.close();
        }

        return response;

    }
View Full Code Here

        assertThrows(ErrorCode.CONNECTION_BROKEN_1, this).
                getConnection("jdbc:h2:tcp://localhost:9001/test");
        final ServerSocket serverSocket = new ServerSocket(9001);
        Task task = new Task() {
            public void call() throws Exception {
                Socket socket = serverSocket.accept();
                byte[] data = new byte[1024];
                data[0] = 'x';
                socket.getOutputStream().write(data);
                socket.close();
            }
        };
        task.execute();
        Thread.sleep(100);
        try {
View Full Code Here

  public void header() throws IOException {
    super.header();
    try {
      URL url = new URL("https://" + getFile());
      int i = url.getPort();
      socket = new Socket(url.getHost(), i == -1 ? url.getDefaultPort()
          : i);
      socket.setSoTimeout(((HttpsService) connection.element).timeout);
      outputstream = new BufferedOutputStream(socket.getOutputStream());
      session.getServer().head(getVersion(), ServerStream.OK,
          "Connection established");
View Full Code Here

   * @param timeout  the timeout value to be used in milliseconds.
   */
  public Socket createSocket(InetAddress addr, int port,
                             int timeout) throws IOException {
    if (timeout == 0)
      return new Socket(addr, port);

    // AF (TODO): To be provided
    throw new UnsupportedOperationException();
  }
View Full Code Here

   */
  public Socket createSocket(InetAddress addr, int port,
                             InetAddress localAddr, int localPort,
                             int timeout) throws IOException {
    if (timeout == 0)
      return new Socket(addr, port, localAddr, localPort);

    // AF (TODO): To be provided
    throw new UnsupportedOperationException();
  }
View Full Code Here

TOP

Related Classes of java.net.Socket$SocketOutputStream

Copyright © 2018 www.massapicom. 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.