If the client and the server agree on protocol version 1 after negotiation, the client starts communicating using that protocol. First, the client selects the method and requests it from the server. Then the server accepts the request and continues the communication.
Method code | Method name |
---|---|
1 | Get Text |
2 | Send Text |
3 | Get Files |
4 | Send File |
5 | Get Image/Screenshot |
125 | Info |
When the server receives a method request from the client, it will respond to the client with one of the following status codes. The status code will be sent to the client as a single byte. For example, if the status code is 1, the server sends the byte \x01.
Status code value | Status code name | Description |
---|---|---|
1 | OK | The method is accepted. If this method is to send data to the server, the client can now start sending data. If this method is to get data from the server, the server will now start sending data. |
2 | NO_DATA | This status occurs only for methods that get data from the server (ex: get_text, get_files). This status implies that the method is valid and accepted, but the server has no data to send (possibly because there is no text or files copied into the clipboard of the server device). Therefore, the communication ends at this point, and the connection can be closed now. |
3 | UNKNOWN_METHOD | This status code is sent when the client requests an invalid method request code. The request is rejected, and the communication ends at this point. Therefore, the server and the client can close the connection. |
4 | METHOD_NOT_IMPLEMENTED | This status code implies that the method request code is valid. However, the server does not implement that method. Therefore, the request has to be rejected. The communication ends at this point, and the connection can be closed now. |
The following methods are supported in this protocol version.
Notes:
This method is used to get the copied text from the server to the client. Once the client requests this method code from the server and the server acknowledges the client with the status OK, the server will send the length of the copied text followed by the copied text to the client. Once the copied text is transmitted, the communication ends, and the connection can be closed. The client may copy the received text to the clipboard of the client device.
This method is used to send the copied text from the client to the server. Once the client requests this method code from the server and the server acknowledges the client with the status OK, the client will send the length of the copied text followed by the copied text to the server. Once the copied text is transmitted, the communication ends, and the connection can be closed. The server may copy the received text to the clipboard of the server device.
This method is used to get the copied files from the server to the client. This method only supports sending
regular files (i.e., directories, links, or other types are not supported). Once the client requests this
method code from the server and the server acknowledges the client with the status OK, the server will send
the number of files encoded as a numeric value as specified above in the notes. After sending the number of
files, each file is sent sequentially, as follows.
This method is used to send a file from the client to the server. This method only supports sending a single
regular file at a time (i.e., directories, links, or other types are not supported). Once the client
requests this method code from the server and the server acknowledges the client with the status OK, the
client will send the file to the server as follows.
This method is used to get a copied image or a screenshot from the server to the client. If the server
device has an image copied to the clipboard, it will be sent. Otherwise, a screenshot of the server device
will be sent as an image. The image gets encoded as a PNG image. Once the client requests this method code
from the server, and if the server can get the image, the server acknowledges the client with the status OK.
Then, the server will send the image as follows.
This method is used to get the name of the server. Once the client requests this method code from the server, and the server acknowledges the client with the status OK, the server will send the length of the name, followed by the server's name, "clip_share", to the client. Once the name is transmitted, the communication ends, and the connection can be closed.