Article View: borland.public.jbuilder.java.language
Article #14540socket pbm. :Server's o/p not produced in echo protocol
From: Badri Veera
Date: Fri, 20 Aug 1999 00:00
Date: Fri, 20 Aug 1999 00:00
56 lines
2204 bytes
2204 bytes
Hi:
I'm trying to implement a echo protocol. In this the client opens a socket
to port 7 on the echo server, sends data, and the server sends the data
back.
The problem is that, when the user types the data, the server side output is
not printed through pout.println(..) statement, but the response form the
server is printed through the System.out.println( .readLine()) statement.
It doesn't give any errors or exceptions.
Can anybody tell me why the server side o/p is not being printed.
Thanx
Mini
public static void main(String[] args)
{
Socket socket;
BufferedReader bin,userinput;
PrintWriter pout;
try
{
socket = new Socket("www.provide.net", 7 );
bin = new BufferedReader(new
InputStreamReader(socket.getInputStream()));
pout = new PrintWriter(socket.getOutputStream(),true);
userinput = new BufferedReader(new
InputStreamReader(System.in));
String theline = userinput.readLine();
pout.println(theline);
// server o/p
System.out.println("Server's response ----> " +
bin.readLine()); // client o/p
}
catch(UnknownHostException uhe)
{ System.out.println("UnknownHost");
return;
}
catch(IOException e)
{ System.out.println("Connection not established");
return;
}
System.out.println("disconnecting");
try
{ socket.close(); }
catch( IOException e)
{ System.out.println("error closing socket");
return;}
}
Technical Details
Message-ID:
<37bd8f52.0@news.provide.net>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,f35bf614bf16ca35,start X-Google-Attributes: gidf74b3,public From: "Badri Veera" <rugveera@provide.net> Subject: socket pbm. :Server's o/p not produced in echo protocol Date: 1999/08/20 Message-ID: <37bd8f52.0@news.provide.net> X-Deja-AN: 515181910 X-Trace: 20 Aug 1999 13:24:34 -0400, usr13-066.provide.net Newsgroups: borland.public.jbuilder.java.language X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3