Dear Friends ,
I want to implement simple client - server communication .
My server is already running , then i'm separately running my Client.
At console i'm going to make an input . It will be read as a readLine.
The same will be displayed at Server side.
If instead of Client , if i use , Telnet it works appropriately .
Can anybody please tell me whats wrong ?
from ,
Vikram .
///////////// Server Side Code ////////////////////////
public class Server
{
public static void main(String[] args)throws IOException
{
ServerSocket servsock = new ServerSocket(4444);
System.out.println("Server is running");
Socket soc;
for(;

{
soc = servsock.accept();
System.out.println("Until here is OK ! - 0");
InputStreamReader isr = new InputStreamReader(soc.getInputStream());
BufferedReader br = new BufferedReader(isr);
String str = br.readLine();
System.out.println("Until here is OK ! - 1");
System.out.println("String received at Server : "+str);
// THIS PROGRAM WORKING FINE WITH TELNET uptill this
}
}
}
//////////////// Client Side Code ////////////////////////
public class Client
{
public static void main(String[] args)throws IOException
{
//BUFFERED READER TO INPUT STREAM
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String input = in.readLine();
Socket sock = new Socket(InetAddress.getLocalHost(),4444);
OutputStreamWriter osw = new OutputStreamWriter(sock.getOutputStream());
osw.write(input,0,input.length());
System.out.println("String for Server is : "+osw);
}
}