Write a program for connecting server with client like google.com with ip address of it.

// java socket client example
import java.io.*;
import java.net.*;
public class socket_client
{
Public static void main(String[] args) throws IOException
{
Socket s = new Socket();
String host = “www.google.com”;
Try
{
s.connect(new InetSocketAddress(host,80));
}
//Host not found
catch(UnknownHostException e)
{
System.out.println(“Dont know about this host: ” +host);
System.exit(1);
}
System.out.println(“Connected”);
}
}

Comments

Popular posts from this blog

Write a java program to create Teacher table(TNo.TName, Sal, Desg) and insert a record in it.

Create a JSP page to accept a number from an user and display it in words: Example: 123 – One Two Three. The output should be in red color.

Write a JSP program to accept the details of Account (ANo, Type, Bal) and store it into database and display it in tabular form. (Use PreparedStatement interface)