Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with InputStreamReader in UNIX  RSS feed

 
Jose Cao
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have the folowing code:
1 Socket socket = new Socket(host, port);
2 PrintWriter sout =
new PrintWriter(socket.getOutputStream(),true);
3
4 BufferedReader sin = new BufferedReader(
5 new InputStreamReader(
6 socket.getInputStream()));
7
8
9 InputStreamReader sin =
new InputStreamReader(socket.getInputStream());
10 // I read the firts line produced by the
// remote machine
11 String line = sin.readLine();
12 line = sin.readLine();
13
14
15 // I put login and password to the remote machine
16 sout.println(login);
17 sout.println(passwd);
18
19 line = sin.readLine();
20
21 // I put the command to the remote machine
22 sout.println("hssdp:snb=158" + nro_telf + ",list;");
When I execute this code in Windows 2000 everything works fine.
When I excute this code in UNIX (Solaris) everything works fine
until line 19. When the program reach line 19, it stays hold and do
nothing else. What could be the problem ???
Please help !!!
Thanks in advance.
[ November 06, 2002: Message edited by: Jose Cao ]
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're waiting for a response from a socket. Is the socket configuration correct for your UNIX machine? Are you sure the socket's response is the same on the UNIX machine? Perhaps it's written something, but did not end with a newline - so readLine() is still waiting for the newline. Just for debugging, try inserting:

Put this just before (instead of) the readLine(). This will allow you to see if anything has been written by the socket.
 
Jose Cao
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for your help !!!
It was very useful for me !!!
Bye.
Originally posted by Jose Cao:
Hi,
I have the folowing code:
1 Socket socket = new Socket(host, port);
2 PrintWriter sout =
new PrintWriter(socket.getOutputStream(),true);
3
4 BufferedReader sin = new BufferedReader(
5 new InputStreamReader(
6 socket.getInputStream()));
7
8
9 InputStreamReader sin =
new InputStreamReader(socket.getInputStream());
10 // I read the firts line produced by the
// remote machine
11 String line = sin.readLine();
12 line = sin.readLine();
13
14
15 // I put login and password to the remote machine
16 sout.println(login);
17 sout.println(passwd);
18
19 line = sin.readLine();
20
21 // I put the command to the remote machine
22 sout.println("hssdp:snb=158" + nro_telf + ",list;");
When I execute this code in Windows 2000 everything works fine.
When I excute this code in UNIX (Solaris) everything works fine
until line 19. When the program reach line 19, it stays hold and do
nothing else. What could be the problem ???
Please help !!!
Thanks in advance.
[ November 06, 2002: Message edited by: Jose Cao ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!