Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

Java Programmers Help!


ghost's Avatar
0 0

Hi everyone, this is my problem, im trying to write a handshake for a chat server. I'm nearly there its just one thing im stuck with, it a programming problem because I know what to send in order to login, if you guys could help me with this it would be great, okay I'll explain:

The first thing i have to do is send my nick i want to login with, if only it was that easy…

This is what a successful handshake looks like:

// Connected

Client: aNICK#sessionID
Server: ~z
Client: ~a
Server: ~a#56#12#34#78#67#

At this point, the last string the server sends back is sent into the handshake argument, before the handshake is sent doHandshake(server_response), the last string read must be ~a#34#56#21#33#44#, (the numbers dont haveto be to that exact, they change each time) thats as best i can explain it, then when a successful handshake is done, the server sends back "a" (without quotes).

So I'm trying to do this in java, but its hard cos I have to use while loops. Basically I have to keep reading from the server and sending something until I get back what I want, This is what I've tried so far:

if any of you have better ways of reading from a server, please tell me what im doing wrong!

      util.send("a" + nick + "#" + sID);
      reader = new BufferedReader(new InputStreamReader(util.in));


//ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - Start Handshake

	try { res = reader.readLine(); } catch(IOException IOE) {}

        util.send("~a");

	   while(!res.contains("#"))
	   {
	     util.prt("loop 1 " + res);
	   }
	       doHandshake(res);


//ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ - End Handshake

	         // Logged in

if any of you guys can help it would be great, thank you.


ghost's Avatar
0 0

not sure if this is what you want, but this is the order you loginto IRC with:

telnet irc.host.net 6667
'get what they send'
'chekc for ping and repl to it if there is one'
USER username username username username ; this isnt totally true just the easiest way eahc place is for anothter thing
*ping check/rply*
NICK nick nick nick ; again same as above
*ping check/reply*
JOIN #channel
PRIVMSG #channel : message
QUIT ;exit

#but you probably jknow that