1

I'm writing a socket server in python. It needs to send acknowledgement to the client module. Quote from the protocol description:

"[...]server should determine if it would accept data from this module. If yes server will reply to module 01 if not 00."

I implemented this in python as:

connection.send('01')

It isn't working, so I checked the java implementation of the server:

        byte[] answer = {
            0x01};
        out.write(answer);
        out.flush();

I wonder whether it's the same or not? The System.out.write(answer); doesn't seem to output a thing to the console.

1 Answer 1

5

You're sending two bytes, 0x30 followed by 0x31, whereas the Java code is sending just one byte, 0x01.

Try the following instead:

connection.send('\x01')

In case you're wondering where the 0x30 and 0x31 came from, they are ASCII codes for the characters '0' and '1'.

Sign up to request clarification or add additional context in comments.

3 Comments

connection.send('\x01') maybe?
@ulidtko: Same thing (the two are exactly equivalent).
@aix, but '\x01' is much more closer to Java's byte[] {0x01}.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.