Server supports two types of network connections: web socket and raw TCP/IP connection. Web socket connection is used by browsers to connect to the server. Raw TCP/IP connections maybe used by bots and AI agents to simplify network protocol development.
Web socket connections must always be in binary format. Sending any non-binary message to the server will terminate the connection. Web socket is default connection type and no extra actions required to enabled it. Browser and server will perform handshake automatically. From java script perspective, it is very trivial to establish binary connection:
WebSocket('ws://ageofmempires.com:23917');
socket.binaryType = 'arraybuffer';
Production server always operates on port 23917, test server is on 23929.
Bots and AI agents may choose the connection type. By default, web socket connection is used. To switch to raw TCP/IP connection, client must send C2S::GM message as the very first message. This message replaces web socket handshake. Don't worry about fragmented messages, server is smart enough to assemble the fragments into full messages.