Server Program:
import java.io.*;
import java.net.*;
class Server{
public static void main(String args[]){
try{
ServerSocket ss = new ServerSocket(8080);
Socket s = ss.accept();
DataInputStream dis = new DataInputStream(s.getInputStream());
String str = (String)dis.readUTF();
System.out.println("Message : "+str);
ss.close();
}catch(Exception e){
System.out.println(e);
}
}
}
Client Program:
import java.io.*;
import java.net.*;
class client{
public static void main(String args[]){
try{
Socket s = new Socket("localhost",8080);
DataOutputStream dos = new DataOutputStream(s.getOutputStream());
dos.writeUTF("Hello friend ");
dos.flush();
dos.close();
s.close();
}catch(Exception e){
e.printStackTrace();
}
}
}
When I execute this program. I got an error like this "java.net.BindException: Address already in use: JVM_Bind" But before it works fine. Please anyone help me with this issue?