Is there any easy way to transfer 4 bit integer on socket? I want to send like this: a=5 send_integer(socket_s,a) and receive like this: a=receive_integer(socket_s) Sending and receiving is in binary form, not transfer it to string. Is there any easy way to do this?