Programming error in Java Socket
Posted
by
Akhil K Nambiar
on Stack Overflow
See other posts from Stack Overflow
or by Akhil K Nambiar
Published on 2011-11-23T09:47:14Z
Indexed on
2011/11/23
9:50 UTC
Read the original article
Hit count: 209
Can you tell me what is the error in this code?
Socket socket = new Socket(hostname, port);
PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
//DataInputStream is = new DataInputStream(socket.getInputStream());
out.println("hi");
System.out.print(in.readLine());
The Server Socket program is written in .Net and it echoes back the data. The data is sent successfully but could not be retrieved properly. I tried the same by using the linux command
nc 192.168.1.6 8425 (enter)
Hi (Sent data)
Hi (recieved data)
When I checked the code the data is found to have sent as byteStream in .Net. Is that a problem. In that case what modification should I make.
© Stack Overflow or respective owner