Connect with a Web server : Web Server Client « Network Protocol « Java

Connect with a Web server

Connect with a Web server

public class WebPing {
  public static void main(String[] args) {
    try {
      InetAddress addr;
      Socket sock = new Socket("", 80);
      addr = sock.getInetAddress();
      System.out.println("Connected to " + addr);
    } catch ( e) {
      System.out.println("Can't connect to " + args[0]);

Related examples in the same category

1.Java HTTP/HTTPS Server Based on new io
2.Reading URLs Protected with HTTP Authentication
3.Reading Web Pages with StreamsReading Web Pages with Streams
4.Reading Web Pages, with Socket ChannelsReading Web Pages, with Socket Channels
5.Reading Web Pages with Nonblocking ChannelsReading Web Pages with Nonblocking Channels
6.A Simple Web ServerA Simple Web Server
7.Web server
8.Save binary file from web