Simple Socket programming using TCP in java
import java.io.*;
import java.net.*;
class Server
{
public static void main(String[] a) throws IOException
{
ServerSocket ss=new ServerSocket(29);
Socket s=ss.accept();
System.out.println(s);
}
}
class Client
{
public static void main(String[] a) throws IOException
{
Socket s=new Socket("192.168.8.38",29);
System.out.println(s);
}
}
Output
import java.net.*;
class Server
{
public static void main(String[] a) throws IOException
{
ServerSocket ss=new ServerSocket(29);
Socket s=ss.accept();
System.out.println(s);
}
}
class Client
{
public static void main(String[] a) throws IOException
{
Socket s=new Socket("192.168.8.38",29);
System.out.println(s);
}
}
Output

Comments
Post a Comment