Home  >  Article  >  Database  >  Introduction to the exit command package and parsing code of the mysql protocol

Introduction to the exit command package and parsing code of the mysql protocol

黄舟
黄舟Original
2017-03-07 14:03:301345browse

git

https://github.com/sea-boat/mysql-protocol

Overview

After the mysql client connects to the mysql server, when it needs to exit and disconnect, it sends an exit command to the server. The server can directly close the connection or return an OK packet.

mysql communication message structure

##string payloadMessage body, the length is the previously specified payload length
TypeNameDescription
int5bdf4c78156c7953567bb5a0aef2fc53payload lengthStored according to the least significant byte first, 3-byte payload and 1-byte sequence number combination Into the message header
intf35d6e602fd7d0f0edfa6f7d103c1b57sequence number
Exit command package

Payload

1              [01] COM_QUIT

More details: http://dev.mysql.com/doc/internals/en/com-quit.html

Quit Command package class

/**
 * 
 * @author seaboat
 * @date 2016-09-25
 * @version 1.0
 * 
email: 849586227@qq.com
*
blog: http://www.php.cn/;/pre>
 * 

quit command packet.

*/public class QuitPacket extends MySQLPacket { // payload length is 1,packet id is 0,payload is 1 public static final byte[] QUIT = new byte[] { 1, 0, 0, 0, 1 }; @Override public int calcPacketSize() { return 1; } @Override protected String getPacketInfo() { return "MySQL Quit Packet"; } }

The above is the introduction of the exit command package and parsing code of the mysql protocol. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn