Package java.net

Examples of java.net.Socket.connect()


                channel = SocketChannel.open(addr);
            } else {
                channel = SocketChannel.open();
                Socket socket = channel.socket();
                socket.bind(new InetSocketAddress(InetAddress.getByName(localHost), localPort));
                socket.connect(new InetSocketAddress(InetAddress.getByName(remoteHost), remotePort));
            }
            channel.finishConnect();
            initSocket(context.getRuntime(), new ChannelDescriptor(channel, RubyIO.getNewFileno(), new ModeFlags(ModeFlags.RDWR), new FileDescriptor()));
        } catch (InvalidValueException ex) {
            throw context.getRuntime().newErrnoEINVALError();
View Full Code Here


  private void connectAndClose(InetSocketAddress addr)
  {
    try {
      Socket socket = new Socket();

      socket.connect(addr, 100);

      socket.close();
    } catch (ConnectException e) {
    } catch (Throwable e) {
      log.log(Level.FINEST, e.toString(), e);
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

            // Not in cache, so create new one and cache it
            try {
                closeSocket(); // Bug 44910 - close previous socket (if any)
                SocketAddress sockaddr = new InetSocketAddress(getServer(), getPort());
                con = new Socket();
                con.connect(sockaddr, getConnectTimeout());
                log.debug("Created new connection " + con); //$NON-NLS-1$
                cp.put(TCPKEY, con);
            } catch (UnknownHostException e) {
                log.warn("Unknown host for " + getLabel(), e);//$NON-NLS-1$
                cp.put(ERRKEY, e.toString());
View Full Code Here

            if (this.session.getDebug()) {
                this.session.getDebugOut().println("connecting to " + mail_host);
            }

            s.connect(new InetSocketAddress(mail_host, port));

            if (this.session.getDebug()) {
                this.session.getDebugOut().println("connected to " + mail_host);
            }
        }
View Full Code Here

        failures++;
        continue;
      }
      try {
        s = new Socket();
        s.connect(targetAddr, FSConstants.READ_TIMEOUT);
        s.setSoTimeout(FSConstants.READ_TIMEOUT);
       
        blockReader =
          DFSClient.BlockReader.newBlockReader(s, targetAddr.toString() + ":" +
                                               block.getBlockId(),
View Full Code Here

    private void sendCommand(String command) {
        if (socketAddress != null) {
            Socket socket = null;
            try {
                socket = new Socket();
                socket.connect(socketAddress);
                writeLine(socket, command);
                String result = readLine(socket);
                log.info("Sent '" + command + "' to " + socketAddress + ": " + result, null);
            } catch (ConnectException ce) {
                log.info("No Sling running at " + socketAddress, null);
View Full Code Here

            return createSocket( sHost, nPort, aLocalAddress, nLocalPort );

        int nTimeout = params.getConnectionTimeout();
        Socket aSocket = GetNotSoSecureSSLContext().getSocketFactory().createSocket();
        aSocket.bind( new InetSocketAddress( aLocalAddress, nLocalPort ) );
        aSocket.connect( new InetSocketAddress( sHost, nPort ), nTimeout );
        return aSocket;
    }

    public Socket createSocket( String sHost, int nPort )
        throws IOException, UnknownHostException
View Full Code Here

        try {
            Socket pingSocket = new Socket();
            // On Windows, the firewall doesn't respond at all if you connect to an unbound port, so we need to
            // take lack of a connection as an empty port. Timeout is 1000ms.
            try {
                pingSocket.connect(new InetSocketAddress(service.getHost(), port), 1000);
            } catch (SocketTimeoutException ste) {
                return false;
            }
            pingSocket.close();
            if (VERBOSE_PORT_SCAN) {
View Full Code Here

    @Override
    public Socket createSocket(String host, int port, InetAddress localHost, int localPort)
            throws IOException, UnknownHostException {
        Socket socket = applySettings(createSocket());
        socket.bind(new InetSocketAddress(host, localPort));
        socket.connect(new InetSocketAddress(host, port));
        return socket;
    }

    @Override
    public Socket createSocket(String host, int port) throws IOException, UnknownHostException {
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.