Practical
: 1
Subject
: Advanced JAVA
Aim : Implement the connection oriented client server application
Source
Code :
//ser1.java
import java.net.*;
import java.io.*;
class ser1
{
public
static void main(String[] args) throws Exception
{
ServerSocket
ss = new ServerSocket(8);
Socket
s = ss.accept();
DataInputStream
din = new DataInputStream(s.getInputStream());
String
str = (String)din.readUTF();
System.out.println("msg
: "+str);
ss.close();
}
}
cli1.java
import java.net.*;
import java.io.*;
class cli1
{
public
static void main(String[] args) throws Exception
{
Socket
s = new Socket("Localhost",8);
DataOutputStream
dout = new DataOutputStream(s.getOutputStream());
dout.writeUTF("Pratik
Says Hello World");
s.close();
}
}
Output
:
0 comments:
Post a Comment