change write int to write 4 bytes
add magic number for protocol