Example usage for java.net Socket Socket

List of usage examples for java.net Socket Socket

Introduction

In this page you can find the example usage for java.net Socket Socket.

Prototype

public Socket(InetAddress address, int port) throws IOException 

Source Link

Document

Creates a stream socket and connects it to the specified port number at the specified IP address.

Usage

From source file:Main.java

public static void main(String[] args) throws Exception {
    Socket client = new Socket("google.com", 80);
    client.setSoLinger(true, 1000);/*  ww  w  .  java  2  s. c o m*/
    System.out.println(client.getSoLinger());

    client.close();
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Socket client = new Socket("google.com", 80);
    client.setReuseAddress(true);//from  w  w w  .java  2s .c  om
    System.out.println(client.getReuseAddress());

    client.close();
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Socket client = new Socket("google.com", 80);
    client.setTcpNoDelay(true);/*from w  w w  .  j  av  a2 s. c  o m*/
    System.out.println(client.getTcpNoDelay());

    client.close();
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Socket client = new Socket("google.com", 80);
    client.setSoTimeout(1000);/*from  w  w w  .  j a va2s  .  c  o  m*/
    System.out.println(client.getSoTimeout());

    client.close();
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Socket client = new Socket("google.com", 80);

    System.out.println(client.getReceiveBufferSize());

    client.close();/*from  w  w  w  . j av a  2s. c  o  m*/
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Socket client = new Socket("google.com", 80);

    System.out.println(client.getPort());

    client.close();/*from   ww  w .  j  a v a  2  s . c om*/
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Socket client = new Socket("google.com", 80);

    System.out.println(client.getInetAddress());

    client.close();/*www  . ja v  a 2s.  c  o m*/
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Socket client = new Socket("google.com", 80);

    System.out.println(client.isClosed());

    client.close();/*from   w  w  w  . ja  v  a2s . c om*/
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Socket client = new Socket("google.com", 80);
    client.setKeepAlive(true);//from w w w . j a v a2 s .  c  o m
    System.out.println(client.getKeepAlive());

    client.close();
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Socket client = new Socket("google.com", 80);

    System.out.println(client.isBound());

    client.close();//from   w w w  .  j  a  v  a  2s. co m
}