Package java.net

Examples of java.net.Socket.connect()


        failures++;
        continue;
      }
      try {
        s = new Socket();
        s.connect(targetAddr, FSConstants.READ_TIMEOUT);
        s.setSoTimeout(FSConstants.READ_TIMEOUT);
       
        //
        // Xmit header info to datanode
        //
View Full Code Here


            s.setSoTimeout(soTimeout);
            s.setSoLinger(true ,0);
            if (log.isDebugEnabled()) {
                log.debug("About to unlock socket for: " + saddr);
            }
            s.connect(saddr, unlockTimeout);
            if (log.isDebugEnabled()) {
                log.debug("Socket unlock completed for:"+saddr);
            }
        } catch (Exception e) {
            if (log.isDebugEnabled()) {
View Full Code Here

    private String sendAndReceive(String input) throws IOException {
        byte buf[] = new byte[128];

        Socket soc = new Socket();
        soc.connect(new InetSocketAddress("localhost", PORT));

        // Send message using plain Socket to test if this works
        OutputStream os = null;
        InputStream is = null;
        try {
View Full Code Here

    int port = sp.length > 1 ? Integer.parseInt(sp[1])
        : HConstants.DEFAULT_ZOOKEPER_CLIENT_PORT;

    Socket socket = new Socket();
    InetSocketAddress sockAddr = new InetSocketAddress(host, port);
    socket.connect(sockAddr, timeout);

    socket.setSoTimeout(timeout);
    PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
    BufferedReader in = new BufferedReader(new InputStreamReader(
      socket.getInputStream()));
View Full Code Here

    final int port = uri.getPort() > 0 ? uri.getPort() : GIT_PORT;
    final Socket s = new Socket();
    try {
      final InetAddress host = InetAddress.getByName(uri.getHost());
      s.bind(null);
      s.connect(new InetSocketAddress(host, port), tms);
    } catch (IOException c) {
      try {
        s.close();
      } catch (IOException closeErr) {
        // ignore a failure during close, we're already failing
View Full Code Here

        if (socket != null){
            throw new IllegalStateException("Already got a socket connection?");
        }
        Socket s = new Socket();
        s.setKeepAlive(true);
        s.connect(address);
       
        this.socket = s;
        this.os = socket.getOutputStream();
    }
   
View Full Code Here

                        if(log.isTraceEnabled())
                            log.trace("REGISTER(" + group + ", " + mbr + ") with GossipRouter at " + entry.getIpAddress() + ':' + entry.getPort());
                        sock=new Socket();
                        if(sock_read_timeout > 0)
                            sock.setSoTimeout(sock_read_timeout);
                        sock.connect(new InetSocketAddress(entry.getIpAddress(), entry.getPort()), sock_conn_timeout);
                        out=new DataOutputStream(sock.getOutputStream());
                        GossipData gossip_req=new GossipData(GossipRouter.REGISTER, group, mbr, null);
                        // must send GossipData as fast as possible, otherwise the request might be rejected
                        gossip_req.writeTo(out);
                        out.flush();
View Full Code Here

                        if(log.isTraceEnabled())
                            log.trace("UNREGISTER(" + group + ", " + mbr + ") with GossipRouter at " + entry.getIpAddress() + ':' + entry.getPort());
                        sock=new Socket();
                        if(sock_read_timeout > 0)
                            sock.setSoTimeout(sock_read_timeout);
                        sock.connect(new InetSocketAddress(entry.getIpAddress(), entry.getPort()), sock_conn_timeout);
                        out=new DataOutputStream(sock.getOutputStream());
                        GossipData gossip_req=new GossipData(GossipRouter.UNREGISTER, group, mbr, null);
                        // must send GossipData as fast as possible, otherwise the request might be rejected
                        gossip_req.writeTo(out);
                        out.flush();
View Full Code Here

                    DataInputStream in=null;
                    try {
                        sock=new Socket();
                        if(sock_read_timeout > 0)
                            sock.setSoTimeout(sock_read_timeout);
                        sock.connect(new InetSocketAddress(entry.getIpAddress(), entry.getPort()), sock_conn_timeout);
                        out=new DataOutputStream(sock.getOutputStream());
                        GossipData gossip_req=new GossipData(GossipRouter.GOSSIP_GET, group, null, null);
                        // must send GossipData as fast as possible, otherwise the request might be rejected
                        gossip_req.writeTo(out);
                        out.flush();
View Full Code Here

        Socket socket = channel.socket();
        channel.configureBlocking(true);
        /* Disable Nagle, the client only sends short messages. */
        socket.setTcpNoDelay(tcpNoDelay);
        socket.setSoTimeout(timeout);
        socket.connect(addr);
        return channel;
    }

    /**
     * Chains an old outstanding exception to the tail of a new one, so it's
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.