Valhalla Legends Forums Archive | Java Programming | Java Code for Bot

AuthorMessageTime
snowstorm
Can someone help me out? 
I have no idea why this won't work.  I am just connecting to bnet sending the protocol byte and then packet 0x50, but it only sends the first byte and after that it says [TCP Window Full] and the connection terminates:
[code]
byte[] b = new byte[] {0x01};

byte[] t = {(byte)0xff, 0x50, 0x3a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x38, 
0x58, 0x49, 0x50, 0x58, 0x32, 0x44, 0x0a, 0x00, 0x00, 0x00, 0x53, 0x55, 0x6e, 0x65, (byte)0xC0, (byte)0xA8, 
0x02, 0x44,(byte)0xA4, 0x01, 0x00, 0x00, 0x09, 0x04, 0x00, 0x00, 0x09, 0x04, 0x00, 0x00, 0x55, 0x53, 
0x41, 0x00, 0x55, 0x6e, 0x69, 0x74, 0x65, 0x64, 0x20, 0x53, 0x74, 0x61, 0x74, 0x65, 0x73, 0x00};

out.write(b, 0, b.length);
out.flush();
out.write(t, 0, t.length);
out.flush();
[/code]

These are the packets as captured directly from running d2.

Thanks for any help!
April 15, 2005, 2:02 AM
iago
That looks fine; not good, but fine :P

Post the code where you open the connection, please.

(http://www.javaop.com/javaop2/src if you wanna see a sample of Java bot code, BNetLogin looks after building the 0x50 packet)
April 15, 2005, 4:33 AM
snowstorm
[code]
// Input and output streams for TCP socket
protected DataInputStream in;
protected DataOutputStream out;

protected Socket connect (int port) throws IOException
{
String server = "uswest.battle.net";
// Connect method
System.out.println ("\nConnecting to " + server + " on port " + port + "\n");
Socket socket = new Socket (server, port);
OutputStream rawOut = socket.getOutputStream ();
InputStream rawIn = socket.getInputStream ();
BufferedOutputStream buffOut = new BufferedOutputStream (rawOut);
out = new DataOutputStream (buffOut);
in = new DataInputStream (rawIn);
return socket;
} // END connect
[/code]
Thanks for the help
April 17, 2005, 3:15 PM
iago
Hmm, I've never tried using a DataInputStream/OutputStream.  Try using a standard OutputStream (not buffered, not data) since that can be sent an array of bytes.
April 17, 2005, 3:50 PM

Search