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

  1. Very useful and informative content! I really appreciate the way you explained the concepts in a simple and clear manner. For learners who want practical exposure and hands-on experience, the Best Java Real Time Projects Online Training is a great option to build industry-level skills. Thank you for sharing such valuable information!

    ReplyDelete
  2. Great explanation of Java fundamentals in this post. Having a clear understanding of core Java concepts helps developers write efficient and maintainable code. Those interested in strengthening their basics can check Core JAVA Online Training for practical learning experience.

    ReplyDelete

Post a Comment

Popular posts from this blog

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 SERVLET application to accept username and password, search them into database, if found then display appropriate message on the browser otherwise display error message.

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)