hambeast
Well-Known Member
Hey all,
Wondering if there are any java guys out there that could help shed some light on working with UDP and java.
I am referencing this resource: http://www.battleye.com/downloads/BERConProtocol.txt
What I am trying to do is send a UDP login packet (0x00) and receive a response packet back (0x01 or 0x00).
I am trying to follow JAVA tutorials online regarding client/server behavior using UDP but I am not getting to where I want to be.
I am using the following code:
The problem is that when I run a debug, I get stuck at this line with no response:
I'm not 100% sure if I am doing this the right way or not and honestly have no idea how to specify the packet address that I am sending.
Any help at all will be greatly appreciated.
Wondering if there are any java guys out there that could help shed some light on working with UDP and java.
I am referencing this resource: http://www.battleye.com/downloads/BERConProtocol.txt
What I am trying to do is send a UDP login packet (0x00) and receive a response packet back (0x01 or 0x00).
I am trying to follow JAVA tutorials online regarding client/server behavior using UDP but I am not getting to where I want to be.
I am using the following code:
Code:
protected static void connect() throws Exception{
String pass = "mypass";
DatagramSocket clientSocket = new DatagramSocket();
InetAddress IPAddress = InetAddress.getByName("localhost");
byte[] sendData = new byte[1024];
byte[] receiveData = new byte[1024];
String sentence = pass;
sendData = sentence.getBytes();
DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length, IPAddress, 2302);
clientSocket.send(sendPacket);
DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length);
clientSocket.receive(receivePacket);
String modifiedSentence = new String(receivePacket.getData());
System.out.println("FROM SERVER:" + modifiedSentence);
clientSocket.close();
}
The problem is that when I run a debug, I get stuck at this line with no response:
Code:
DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length);
I'm not 100% sure if I am doing this the right way or not and honestly have no idea how to specify the packet address that I am sending.
Any help at all will be greatly appreciated.