PDA

View Full Version : bot problem #26432


inkedmn
12-12-2002, 01:29 AM
:)

ok, here's the main class that runs the bot:

import joana.*;

public class Joana {

public static void main(String[] args) {
System.out.println("Main started.");
Irc irc = new Irc("irc.oftc.net");
System.out.println("irc object created");
Channel cf = new Channel(irc, "#coderforums");
System.out.println("channel joined");
cf.join();
/*try {
Thread.sleep(10000);
} catch (Exception e) {
System.out.println(e);
return;
}*/
System.out.println("Nick: " + irc.getNick());
irc.die();
}
}


when i run this, it prints the first print statement and then hangs (doesn't create the IRC object - i have a print statement that runs as the constructor is executed, but it never prints).

here's the constructor for Irc:

public Irc(String server) {
System.out.println("IRC constructor called");
this.server = server;
connect(server);
createStreams();
}


all the joana files are in the same directory (including the first file above to run the bot), d:\development\java_practice\joana.
that whole path (except joana) is in my classpath, and i omitted joana because it's a package.

so, i have no idea why the Irc object isn't being created...

Bradmont
12-12-2002, 10:12 AM
methinks you need to give us a bit more info on what connect() and createStreams() do. It seems pretty clear that the problem's in one of those methods.

jamessan
12-12-2002, 10:31 AM
Actually, that's not obvious, Bradmont. As he stated, "Main started" is printed but "IRC constructor called" is not printed. That implies that something isn't happy with 'Irc irc = new Irc("irc.oftc.net");'

inkedmn
12-12-2002, 10:32 AM
Originally posted by jamessan
Actually, that's not obvious, Bradmont. As he stated, "Main started" is printed but "IRC constructor called" is not printed. That implies that something isn't happy with 'Irc irc = new Irc("irc.oftc.net");'

precisely :)

stuka
12-12-2002, 11:17 AM
Ah - but unless I'm completely wrong (which has happened before) using System.out is using a buffered output device - it is still possible that it's hanging AFTER that call (not as likely, but possible). I'd take a look inside your connect() method - and possibly use System.err (that is stderr, right? hafta check that) to print your debug messages since it's unbuffered.

Strike
12-12-2002, 11:25 AM
Well, println isn't buffered I don't think, as it throws a newline at the end. print probably is buffered.

stuka
12-12-2002, 11:57 AM
Strike: if println acts like printf in C, you can have buffering issues (I ran into them in my Concurrent Programming in Unix class).

Bradmont
12-12-2002, 11:58 AM
Originally posted by jamessan
Actually, that's not obvious, Bradmont. As he stated, "Main started" is printed but "IRC constructor called" is not printed. That implies that something isn't happy with 'Irc irc = new Irc("irc.oftc.net");' whoops... my bad... :o

sicarius
12-12-2002, 07:50 PM
no. I don't think that println is buffered.

inkedmn
12-12-2002, 09:11 PM
come to think of it, i don't think it is either...

bwkaz
12-12-2002, 09:33 PM
Well, the buffering is not a function of the function you call, println. It's a function of the stream itself. According to the API specification, System.out is a PrintStream, and the documentation for that class is here:

http://java.sun.com/j2se/1.4.1/docs/api/java/io/PrintStream.html

According to what I can glean from that, PrintStreams are buffered. There is an option you can pass to the constructor to make it auto-flush after a println() call, after a '\n' is written, or after a byte array is written, which makes println() behave like it's unbuffered, but it still is buffered. If, somehow, the stream gets interrupted for whatever reason, it is possible that the output doesn't get printed. However, this is pretty much impossible (AFAIK) unless your program is multithreaded, so... yeah.

As to the original problem, hmm... I have no idea. :(

jamessan
12-13-2002, 12:20 AM
Have you tried breaking 'Irc irc=new Irc("irc.oftc.net");' into two seperate lines and putting println statements around each of those? I don't see anything wrong with the code unless we're all overlooking something really stupid. So, I'd go with breaking everything down to the least amount of work per statement and see how far it gets.

inkedmn
12-30-2002, 10:34 AM
update:

my classpath was jacked :)