Locker Server Communication Protocol

Source: Internet
Author: User
The development of the alpha version of the locker server is in the final stage. So far, the main network communication work has been completed. Therefore, the communication protocol of the locker server has been determined.
The operations of the locker server include obtaining the lock, releasing the lock, querying the lock status, batch obtaining the lock, batch releasing the lock, and batch querying the lock status. These operations are divided into two parts: request and response. In Program These operations are replaced by a byte value. The details are as follows:
    • Request_get_locker 127
    • Request_batch_get_locker 126
    • Request_release_locker 125
    • Request_batch_release_locker 124
    • Request_query_locker 123
    • Request_batch_query_locker 122
    • Response_get_locker 1
    • Response_batch_get_locker 2
    • Response_release_locker 3
    • Response_batch_release_locker 4
    • Response_select_locker 5
    • Response_batch_select_locker 6

each time a client requests a server, it first connects to the server through a socket and then sends data. Data is sent in two ways: the first request header and the second request body. The header is defined as:
typedef struct request
{< br> char cmd;
int number;
u_int64_t length;
}request_t;
cmd indicates an operation item above. number indicates the number of objects to be requested, released, or queried, and length indicates the length of the Request body.
The Request body is a string consisting of char, which is generally composed of key values that uniquely identify an object in the system. In addition, an object key value is separated by a separator between two key values. The macro definition of the separator temporarily interrupted by the Service: item_separator "#! @ ^ $ #". The request body is:
"Object ID" + item_separator + "Object ID" + item_separator + "Object ID"
the length in the Request Header, the length of the string.

after the request is received and processed, the server returns the result to the client. The return structure is used, which is defined as follows:
typedef struct response
{< br> char cmd;
char result;
}response_t;
cmd indicates the operation described above, result is the result of this operation. If an error occurs in the program, the error code is sent to the client. This completes the request.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.