ClipShare
Client-Server Communication Protocol
The client and the server communicate through a TCP connection. The server listens on TCP port 4337 for
unencrypted connections and 4338 for encrypted connections, which may be changed from the configuration. The
client connects to the server and starts communicating. The client initiates the communication by selecting
the protocol version. To decide on the protocol version, the client negotiates with the server.
Protocol version negotiation
-
The client starts by sending the protocol version in a single byte (ex: if the protocol version is 1,
the client sends \x01). The version numbers can range from 1 to 253. The client should always send the
highest protocol version it supports.
-
If the server supports that version, it accepts the protocol version and acknowledges the client by
responding with a single byte of value \x01, which denotes that the protocol is supported. It will end
the protocol version negotiation phase. The client can now continue communicating using the selected
protocol version.
-
If the server does not support that protocol version, and if the requested protocol version is less than
the lowest version the server is supporting, the server informs the client by responding with a single
byte of value \x02, which denotes that the protocol is obsolete and not supported. It will be the end of
the communication as there can be no compatible protocol versions between the client and the server
since the highest protocol version supported by the client is less than the lowest version supported by
the server. Therefore, this ends both the negotiation phase and the entire communication. Now, the
client and the server will close the connection.
-
If the server does not support that protocol version, and if the requested protocol version is higher
than the highest version the server is supporting, the server informs the client by responding with a
single byte of value \x03, which denotes that the protocol is unknown to the server and not supported.
Then, the server sends the highest protocol version it can support in a single byte to the client to
offer the chance to use that protocol version if the client supports it. Negotiation continues if the
client accepts this protocol version.
-
If the client supports the protocol version offered by the server, it will acknowledge that to the
server by sending the accepted protocol version back to the server in a single byte. This protocol
version is now accepted by both the server and the client. It will end the protocol version negotiation
phase. The client can now continue communicating using the selected protocol version.
-
If the client does not support the offered protocol version, it rejects the offer by replying to the
server with a single byte \x00. It implies that there can be no compatible protocol versions between the
server and the client. Therefore, this ends both the negotiation phase and the entire communication.
Now, the client and the server will close the connection.
Protocol versions
Currently, the following protocol versions are supported by this server.
Examples