[ SENDER SIDE ]
import java.io.*;
import java.net.*;
public class sender
{
public static void main(String args[]) throws Exception
{
String msg="HELLO WORLD";
Socket soc=new Socket("localhost",3030);
DataOutputStream dos=new DataOutputStream(soc.getOutputStream());
dos.writeUTF(msg);
}
}
[ RECEIVER SIDE ]
import java.io.*;
import java.net.*;
public class receiver
{
public static void main(String args[]) throws Exception
{
String msg;
ServerSocket ss=new ServerSocket(3030);
Socket soc=ss.accept();
DataInputStream dis=new DataInputStream(soc.getInputStream());
msg=dis.readUTF();
System.out.println("Data received is : "+msg);
}
}
No comments:
Post a Comment