• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 794
  • Last Modified:

simple Telnet app, empty read buffer

I am trying to write a Telnet interface to ICC, the Internet Chess Club.  Attached is the code I have so far.  Wireshark shows that when I run this program, the message "Welcome to the INTERNET CHESS CLUB" is sent across the wire, but the read buffer is empty at line 59.  Why is the buffer empty and/or how should I be reading from the socket?
Main.java
0
blackfrancis75
Asked:
blackfrancis75
  • 8
  • 7
  • 4
1 Solution
 
CEHJCommented:
What happens when you use a telnet app to do the same?
0
 
blackfrancis75Author Commented:

telnet> open chessclub.com
Trying 207.99.83.228...
Connected to chessclub.com.
Escape character is '^]'.
Welcome to the INTERNET CHESS CLUB

web:   www.chessclub.com    email: icc@chessclub.com
phone: 1-412-521-5553

login:
0
 
CEHJCommented:
So what gets printed - a solitary right angle bracket?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
blackfrancis75Author Commented:
yes.  I also checked the buffer (using Eclipse debugger) and it appears to be empty
0
 
CEHJCommented:
Configure it to be blocking and you'll probably find it'll read something. If you want non-blocking, you should probably use a Selector
0
 
CEHJCommented:
Another consideration is that a telnet stream contains control characters, so will not decode completely as text
0
 
blackfrancis75Author Commented:
yeah, that's why I checked that the buffer was actually empty using the debugger.

I don't get it though - this is the documented nio.* way to open a socketchannel and read from it. I'd like to understand why it doesn't work.
0
 
CEHJCommented:
0
 
objectsCommented:
commons net supports telnet out of the box

http://commons.apache.org/net/

no need to reinvent the wheel
0
 
blackfrancis75Author Commented:
CEHJ: If I run that program with parameters: chessclub.com 23
it hangs at line 52:  
mIn.read(buf);
indefinitely
0
 
objectsCommented:
> Another consideration is that a telnet stream contains control characters, so will not decode completely as text

How would control chars cause it to "not decode completely"?
And how would that cause a read() to block anyway?
0
 
blackfrancis75Author Commented:
CEHJ: objects really doesn't like you today
0
 
objectsCommented:
his comments are getting a little questionable ;)
0
 
blackfrancis75Author Commented:
perhaps you can comment on why my code wont work ;).  I looked at commons-net but would prefer to use my own basic implementation, if it can work.
0
 
objectsCommented:
sorry don't have the time available. I only spend a small amount of time on EE these days.
0
 
CEHJCommented:
Actually i've tried it with a telnet stream and it behaves weirdly with that too. I can only guess, at this point, that the server could be disallowing automation by screening for 'real' telnet clients.
0
 
blackfrancis75Author Commented:
Using the example code for the Commons-net telnet works fine.  I wish someone could tell me why my original code doesn't work.
0
 
CEHJCommented:
I used commons net telnet too - with weird results
0
 
CEHJCommented:
Just tried it again - seemed ok that time. Possibly an intermittent problem..?
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 8
  • 7
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now