Streams

From: H. Sommers (H.Sommers_at_freeler.nl)
Date: 03/10/05


Date: Thu, 10 Mar 2005 10:52:14 +0100

Can i use the following constructions in a server and client without being
confronted with problems;
The server sometimes (one of every five to twenty times sending without
problems) throws an exception: SocketException: Software caused connection
abort; socket write error.
The client sometimes (also one of every five to twenty) reads an incorrect
(very large) integer.

I want to make use of sending and receiving mixtures of plain text, integers
and pure bytes.

The Server:
// Input
BufferedReader in = new BufferedReader(
    new InputStreamReader(socket.getInputStream()));
// Output
OutputStream out = socket.getOutputStream();
DataOutputStream dout = new DataOutputStream(out);
BufferedOutputStream bout = new BufferedOutputStream(out);
// PrintWriter with autoflush
PrintWriter pout = new PrintWriter(out, true);

The Client:
// Input
InputStream in = socket.getInputStream();
BufferedReader bin = new BufferedReader(new InputStreamReader(in));
BufferedInputStream bisin = new BufferedInputStream(in);
DataInputStream din = new DataInputStream(in);
// Output
// PrintWriter with autoflush
PrintWriter out = new PrintWriter(
     new OutputStreamWriter(socket.getOutputStream()), true);

Thanks for your help!



Relevant Pages

  • Re: Need Desperate Help...Java Sockets
    ... Did you look at the line separator on client and server side? ... See also the private void newLinemethod in PrintWriter. ... > bufferedinput/output streams but when trying to send normal messages ...
    (comp.lang.java)
  • Re: Need Desperate Help...Java Sockets
    ... Did you look at the line separator on client and server side? ... See also the private void newLinemethod in PrintWriter. ... > bufferedinput/output streams but when trying to send normal messages ...
    (comp.lang.java.programmer)
  • Sockets, PrintWriter and BufferedReader question
    ... ok, so i use Sockets, PrintWriter and BufferedReader. ... both client and server will send each other multiple lines ... Socket) on the sender's side when i want to signal end of transmission. ...
    (comp.lang.java)
  • SSL Communication - data sent but not received
    ... with a sniffer) but the server isn't getting the content out - it ... CLIENT SIDE: ... BufferedReader br = new BufferedReader (new InputStreamReader ... SERVER SIDE: ...
    (comp.lang.java.developer)
  • SSL communication losing content data
    ... I am having trouble with a program that transfers data over an SSL ... sent from the client to the server, but when it get to the server the ... both client and server are actually running as servlets on two ... BufferedReader br = new BufferedReader (new InputStreamReader ...
    (comp.lang.java.help)