Package java.net

Examples of java.net.Socket.connect()


    Assert.assertTrue(info.contains("redis_version:"));
  }

  private String testRedis(InetSocketAddress socketAddress) throws IOException {
    Socket socket = new Socket();
    socket.connect(socketAddress);
    socket.getOutputStream().write("INFO\r\n".getBytes());

    StringBuilder sb = new StringBuilder();

    BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
View Full Code Here


    Assert.assertTrue(response.contains("imok"));
  }

  private String testZookeeper(InetSocketAddress socketAddress) throws IOException {
    Socket socket = new Socket();
    socket.connect(socketAddress);
    socket.getOutputStream().write("ruok\n".getBytes());

    String response = IoUtils.readAll(socket.getInputStream());

    socket.close();
View Full Code Here

         int bufferSize = socket.getReceiveBufferSize();
         socket.setReceiveBufferSize(socket_buffer_size);
         if (log.isDebugEnabled())
            log.debug("Connecting to state provider " + address.getIpAddress() + ":" + address.getPort()
                  + ", original buffer size was " + bufferSize + " and was reset to " + socket.getReceiveBufferSize());
         socket.connect(new InetSocketAddress(address.getIpAddress(), address.getPort()));
         if (log.isDebugEnabled())
            log.debug("Connected to state provider, my end of the socket is " + socket.getLocalAddress() + ":"
                  + socket.getLocalPort() + " passing inputstream up...");

         //write out our state_id and address so state provider can clear this request
View Full Code Here

                } else {
                    boolean success = false;
                    Socket proxySocket = null;
                    try {
                        proxySocket = new Socket(proxy);
                        proxySocket.connect(new InetSocketAddress(host, port), connectTimeout);
                        socket = ((SSLSocketFactory) factory).createSocket(proxySocket, host, port, false);
                        success = true;
                    } finally {
                        if (!success) {
                            Utilities.close(proxySocket);
View Full Code Here

        final Socket sock = new Socket();
        sock.setSendBufferSize(chan.getLocalMaxPacketSize());
        sock.setReceiveBufferSize(chan.getRemoteMaxPacketSize());

        sock.connect(addr);

        // ok so far -- could connect, let's confirm the channel
        chan.confirm();

        final Event<IOException> soc2chan = new StreamCopier(sock.getInputStream(), chan.getOutputStream())
View Full Code Here

    Socket s = new Socket();
    s.setTcpNoDelay(true);
    s.setSoTimeout((int) connectionTimeout.getTotalMilliseconds());

    s.connect(socketAddress);

    s.getOutputStream().write(command.getBytes());
    s.getOutputStream().flush();

    // TODO: Timeout?
View Full Code Here

  public boolean isPortOpen(InetSocketAddress socketAddress) throws IOException {
    Socket socket = new Socket();
    try {
      int timeout = 5000;
      socket.connect(socketAddress, timeout);
      return true;
    } catch (IOException e) {
      String message = e.getMessage();
      if (message.equalsIgnoreCase("connect timed out")) {
        return false;
View Full Code Here

    testMemcache(socketAddress);
  }

  private void testMemcache(InetSocketAddress socketAddress) throws IOException {
    Socket socket = new Socket();
    socket.connect(socketAddress);
    socket.getOutputStream().write("stats\n".getBytes());

    BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
    while (true) {
      String line = reader.readLine();
View Full Code Here

    private void dispatch() {
      Socket sock = new Socket();
      DataOutputStream out = null;
      DataInputStream in = null;
      try {
        sock.connect(NetUtils.createSocketAddr(
            target.datanode.getName()), HdfsConstants.READ_TIMEOUT);
        sock.setKeepAlive(true);
        out = new DataOutputStream( new BufferedOutputStream(
            sock.getOutputStream(), FSConstants.BUFFER_SIZE));
        sendRequest(out);
View Full Code Here

    BlockReader blockReader = null;
    Block block = testBlock.getBlock();
    DatanodeInfo[] nodes = testBlock.getLocations();
    targetAddr = NetUtils.createSocketAddr(nodes[0].getName());
    s = new Socket();
    s.connect(targetAddr, HdfsConstants.READ_TIMEOUT);
    s.setSoTimeout(HdfsConstants.READ_TIMEOUT);

    return DFSClient.BlockReader.newBlockReader(
      s, targetAddr.toString()+ ":" + block.getBlockId(),
      block.getBlockId(),
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.