Protocol Version 3

If the client and the server agree on protocol version 3 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.

Selecting the Method

Selecting the method in protocol version 3 is identical to the procedure of selecting the method in protocol version 2.
Method codes in protocol version 3 are almost the same as the method codes in version 2, except for some differences in the Get Files and Send Files methods and some newly added methods. They are described in the Supported Methods section.

Method Codes

Note that some method codes in Version 3 are almost the same as the method codes in Version 2, with some newly added method codes.

The supported method codes and their names.
Method code Method name
1 Get Text
2 Send Text
3 Get Files
4 Send Files
5 Get Image/Screenshot
6 Get Copied Image Only
7 Get Screenshot Only
125 Info

Method Status Codes

Method status codes in protocol version 3 are identical to method status codes of version 2.

Supported Methods

Most of the supported methods are similar to those of Version 2 except for some differences in Get Files, Send Files, and the two newly added methods.
Encoding of lengths, text, file names, file contents, and images and the maximum allowed text lengths, file name lengths, file sizes, and image sizes are identical to those of Version 1 and 2.

Get Text

This method is identical to the Get Text method of Version 1 and 2.

Send Text

This method is identical to the Send Text method of Version 1 and 2.

Get Files

This method is used to get the copied files and directories from the server to the client. The only difference between this method and the Get Files method of Version 2 is that Version 2 does not support sending empty leaf directories, whereas this method of Version 3 supports sending empty leaf directories in addition to files and non-empty directories.

Since this method supports sending empty leaf directories, their file size is transferred as -1, and the file content is considered empty. All other parameters (name length and name) are sent similarly to regular files. The directory name may optionally end with the path separator '/'.

Similarly to the Get Files method of Version 2, the server starts by sending the number of files and then sends each file sequentially. Once all the files are transmitted, the communication ends, and the connection can be closed.

Send Files

This method is similar to the Get Files method except that the client sends the file count and each file/directory sequentially to the server (i.e., the direction of communication after selecting the method is reversed). All the size limits and file path constraints are the same as the Get Files method described above.

Get Image/Screenshot

This method is identical to the Get Image method of Version 1 and 2.

Get Copied Image Only

This method is similar to the Get Image/Screenshot method, except that if there is no image copied to the clipboard, the server will not send a screenshot as the image. Instead, the server will respond with the status NO_DATA to the method request and terminate the connection.

Get Screenshot Only

This method is used to get a screenshot from the server to the client. Even if the server has an image copied to the clipboard, it will send only a screenshot of the server device. The screenshot is encoded as a PNG image. Once the client requests this method code from the server, the server acknowledges the client with the status OK. Then, the client sends the display number from the server, and the server acknowledges the client with the status OK if the display number is valid. Then, the server will send the screenshot. The communication after protocol version negotiation happens as follows.

Once the image is transmitted, the communication ends, and the connection can be closed. Note that the server may not always honor the display number sent by the client. Also note that if the display number is invalid or the server fails to get the screenshot, the server may respond with the status NO_DATA instead of OK and terminate the communication immediately.

Info

This method is similar to the Info method of Version 2 with the exception that this method in version 3 can send some additional name-value pairs describing the server information after the server name. The length field sent first denotes the total length of the response text. The first line of the response text contains the server's name, "clip_share", as in previous versions. Other name-value pairs appear in separate lines, where one line contains a single name-value pair. Lines are separated with LF (i.e. '\n').

A name-value pair is separated by a colon (':'). The name and value fields can contain alpha-numeric characters, period ('.'), hyphen ('-'), and underscore ('_'). In addition to that, the value field may contain any other ASCII characters from '\x20' to '\x7e' inclusive, except colon (':'), which is the name-value separator. The maximum length of the name field is limited to 64 characters, and the maximum length of the value is limited to 256 characters.