T
Tom Dyess
Hi,
I created a newsgroup reader object that communicates with a newsgroup
server and caches articles. It works wonderfully when I run it on a Windows
box, but acts strangely when on a Linux box. Could someone help me, please.
Here is the offending code:
Pseudocode:
- call buildConnection() which creates the socket and sets the in and out
variable pointers
- buildConnection() calls rawAuthenticate() which uses the raw in and out
variables to log into the newsgroup server
the problem is with the rawAuthenticate() method. In Linux, it hangs on the
second in.readLine() as if the server didn't respond to the printline.
You'll see in buildConnection() that I constructed the PrintWriter with the
autoFlush parameter to true. I can't figure out the difference.
Server dialog:
Windows:
200 Powered by Highwinds Software -- http://www.highwinds-software.com/
(Tornado v1.0.6)
AUTHINFO USER account
381 More Authentication Required
Linux:
200 Powered by Highwinds Software -- http://www.highwinds-software.com/
(Tornado v1.0.6)
AUTHINFO USER account
(hangs here - in.readLine() just sits there as if there is no line to read
and eventually sends a timeout message 503.
/**
* Create a socket, set the out and in variables and authenticate to the
server
* based on the object's host and port variables
*
*/
static private synchronized void buildConnection() {
try {
sock = new Socket(host, port);
sock.setKeepAlive(true);
out = new PrintWriter(sock.getOutputStream(), true);
in = new BufferedReader(new InputStreamReader(sock.getInputStream()));
rawAuthenticate();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Send dialog to a connected socket to authenticate to a newsgroup server
* based on the object's login and password variables
* @return if authentication was successful
*/
private static synchronized boolean rawAuthenticate() {
boolean result = true;
String line;
try {
out.println(); // Tell the server there is someone here
if (debug) {System.out.println();}
line = getIn().readLine(); // the header
if (debug) {System.out.println(line);}
// 480 Authentication required for command
out.println("AUTHINFO USER " + login);
if (debug) {System.out.println("AUTHINFO USER " + login);}
line = in.readLine(); // HERE IS THE PROBLEM - THIS NEVER READS
if (debug) {System.out.println(line);}
if (line.startsWith("381")) {
I created a newsgroup reader object that communicates with a newsgroup
server and caches articles. It works wonderfully when I run it on a Windows
box, but acts strangely when on a Linux box. Could someone help me, please.
Here is the offending code:
Pseudocode:
- call buildConnection() which creates the socket and sets the in and out
variable pointers
- buildConnection() calls rawAuthenticate() which uses the raw in and out
variables to log into the newsgroup server
the problem is with the rawAuthenticate() method. In Linux, it hangs on the
second in.readLine() as if the server didn't respond to the printline.
You'll see in buildConnection() that I constructed the PrintWriter with the
autoFlush parameter to true. I can't figure out the difference.
Server dialog:
Windows:
200 Powered by Highwinds Software -- http://www.highwinds-software.com/
(Tornado v1.0.6)
AUTHINFO USER account
381 More Authentication Required
Linux:
200 Powered by Highwinds Software -- http://www.highwinds-software.com/
(Tornado v1.0.6)
AUTHINFO USER account
(hangs here - in.readLine() just sits there as if there is no line to read
and eventually sends a timeout message 503.
/**
* Create a socket, set the out and in variables and authenticate to the
server
* based on the object's host and port variables
*
*/
static private synchronized void buildConnection() {
try {
sock = new Socket(host, port);
sock.setKeepAlive(true);
out = new PrintWriter(sock.getOutputStream(), true);
in = new BufferedReader(new InputStreamReader(sock.getInputStream()));
rawAuthenticate();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Send dialog to a connected socket to authenticate to a newsgroup server
* based on the object's login and password variables
* @return if authentication was successful
*/
private static synchronized boolean rawAuthenticate() {
boolean result = true;
String line;
try {
out.println(); // Tell the server there is someone here
if (debug) {System.out.println();}
line = getIn().readLine(); // the header
if (debug) {System.out.println(line);}
// 480 Authentication required for command
out.println("AUTHINFO USER " + login);
if (debug) {System.out.println("AUTHINFO USER " + login);}
line = in.readLine(); // HERE IS THE PROBLEM - THIS NEVER READS
if (debug) {System.out.println(line);}
if (line.startsWith("381")) {