GMS 2 [Solved] Networking a java server and gms client, trouble receiving data from java server

Solved: Endian problem, switched ByteBuffer order in java and that solved it.

I'm using the ByteBuffer class from java in order to write to a byte[] array, and then I'm sending it as a DatagramPacket through a DatagramSocket.
This is the code:
        byte[] dataOut = new byte[1024];
        ByteBuffer bufferOut = ByteBuffer.wrap(dataOut);
        bufferOut.putInt(MessageTypes.CONNECT_RESPONSE); // 3
        if (good_connect) { // boolean is false if password is incorrect and other checks are failed
            console.log("Client <"+inLoginAlias+"> connected");
            Client client = new Client(console, inetAddress, inLoginAlias, inLoginPassHash, clients.size());
            bufferOut.put((byte) 1);//good connect
        } else {
            bufferOut.put((byte) 0);//bad connect
        DatagramPacket packetOut = new DatagramPacket(dataOut, dataOut.length, inetAddress, PORT_CLIENT);
        try {
        } catch (IOException e) {
            // TODO Auto-generated catch block
So far so good it seems, the packet is sent out correctly and the GMS2 client receives it, here's the async event:
if (async_load[? "type"] == network_type_data) {
    var bufferIn = async_load[? "buffer"];
    buffer_seek(bufferIn, buffer_seek_start, 0);
    var messageId = buffer_read(bufferIn, buffer_s32); /* ERROR HERE */ //reading an int
    show_debug_message("message id: "+string(messageId)); // <==== 16777216
    switch (messageId) {
        case MessageType.CONNECT_RESPONSE:
        //receive response from server to connect request
        var response = buffer_read(bufferIn, buffer_s8);//reading a byte
        if (response == 0) {
            show_debug_message("denied connection");
        } else if (response == 1) {
            show_debug_message("accepted connection");
When the packet is received, the "messageId" shows as 16777216, instead of 3, I have checked the docs and the java int type is a signed 32bit integer (buffer_s32) in the eyes of gamemaker, so what is going wrong?
Last edited: