import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.net.Socket;

public class ByteClient {
    public static void main(String[] args) {
        try {
            Socket s = new Socket("localhost", 2345);

            DataOutputStream dOut = new DataOutputStream(s.getOutputStream());

            byte[] message=new byte[] {(byte)0xA3, (byte)0x1F, (byte)0x2c };
            // when sending an array of bytes, we send first a counter and then the bytes
            dOut.writeInt(message.length); // write the length of the message
            dOut.write(message);           // write the bytes of the message

            dOut.flush();
            dOut.close();
            s.close();
        } catch (Exception e) {
            System.out.println(e);
        }
    }
}
