Package java.net

Examples of java.net.Socket.connect()


   */
  public Socket createSocket(InetAddress addr, int port,
                             int timeout) throws IOException {
    Socket socket = new Socket();
    InetSocketAddress endpoint = new InetSocketAddress(addr, port);
    socket.connect(endpoint, timeout);

    return socket;
  }

  /**
 
View Full Code Here


                             int timeout) throws IOException {
    Socket socket = new Socket();
    InetSocketAddress endpoint = new InetSocketAddress(addr, port);
    InetSocketAddress bindpoint = new InetSocketAddress(localAddr, localPort);
    socket.bind(bindpoint);
    socket.connect(endpoint, timeout);

    return socket;
  }
}
View Full Code Here

    try {
      SocketChannel socketChannel = selector.provider().openSocketChannel();
      Socket socket = socketChannel.socket();
      socket.setTcpNoDelay(true);
      socket.setTrafficClass(IPTOS_LOWDELAY);
      socket.connect(remoteAddress, timeout); // Connect using blocking mode for simplicity.
      socketChannel.configureBlocking(false);
      this.socketChannel = socketChannel;

      selectionKey = socketChannel.register(selector, SelectionKey.OP_READ);
      selectionKey.attach(this);
View Full Code Here

            Socket socket = new Socket();
            socket.setSoTimeout(2000);
            InetSocketAddress socketAddress = new InetSocketAddress(address, port);
            System.out.println("client:" + socketAddress);
            try {
                socket.connect(socketAddress, 2000);
                Thread.sleep(200);
                System.out.println("client:" + socket.toString());
                socket.getOutputStream().write(123);
                Thread.sleep(100);
                System.out.println("client read:" + socket.getInputStream().read());
View Full Code Here

    if (!isRunning()) {
      // no instance of myself is running - check socket
      try {
        Socket socket = new Socket();
        int port = WGADesignerPlugin.getDefault().getPreferenceStore().getInt(PreferenceConstants.TOMCAT_SERVER_PORT);
        socket.connect(new InetSocketAddress("127.0.0.1", port), 1000);
        socket.close();
        return true;
      } catch (IOException e) {
      }
    }
View Full Code Here

          String serverPort = serverElement.attributeValue("port", "8005");
          String shutdownCommand = serverElement.attributeValue("shutdown", "SHUTDOWN");
         
          // send shutdown command to specified port
          Socket socket = new Socket();
          socket.connect(new InetSocketAddress("127.0.0.1", Integer.parseInt(serverPort)), 1000);
          socket.setSoTimeout(5000);
                  OutputStream stream = socket.getOutputStream();
                  for (int i = 0; i < shutdownCommand.length(); i++) {
                      stream.write(shutdownCommand.charAt(i));
                  }
View Full Code Here

    }
    if (sendBufferSize > 0) {
      socket.setSendBufferSize(sendBufferSize);
    }
      socket.setTcpNoDelay(!conserveBandwidth); // enable Nagle's algorithm to conserve bandwidth
      socket.connect(address);
      socket.setSoTimeout(soTimeout);
      return new OioObjectChannel(socket);
  }
 
  public int getSendBufferSize() {
View Full Code Here

     
      int  timeout = TIMEOUT;
       
      long  start = SystemTime.getCurrentTime();
     
      socket.connect( new InetSocketAddress( WHOIS_ADDRESS, WHOIS_PORT ), timeout );
   
      long  end = SystemTime.getCurrentTime();
     
      timeout -= (end - start );
     
View Full Code Here

                    String  result = a_str;
                   
                    try{
                      socket.bind( new InetSocketAddress( ia, 0 ));
                                               
                      socket.connectnew InetSocketAddress( "www.google.com", 80 ), 10*1000 );
                     
                      result += "*";
                     
                    }catch( Throwable e ){
                     
View Full Code Here

     
      if ( time_remaining > 0 ){
       
        socket = new Socket();
       
        socket.connect( new InetSocketAddress( original_url.getHost(), original_url.getPort()==-1?original_url.getDefaultPort():original_url.getPort()), time_remaining );
       
      }else{
   
        socket = new Socketoriginal_url.getHost(), original_url.getPort()==-1?original_url.getDefaultPort():original_url.getPort());
      }
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.