ping Command Package for mysql Protocol and Detailed Resolution and Example
- 2021-06-28 14:22:19
- OfStack
ping Command Package for mysql Protocol and Detailed Resolution
Preface:
MySQL clients can use the ping command to check the status of the server and return the ok package normally.
mysql Communication Message Structure
类型 | 名字 | 描述 |
---|---|---|
int<3> | payload长度 | 按照the least significant byte first存储,3个字节的payload和1个字节的序列号组合成报文头 |
int<1> | 序列号 | |
string | payload | 报文体,长度即为前面指定的payload长度 |
ping Command Pack
Payload
[0e] COM_PING
More details: http://dev.mysql.com/doc/internals/en/com-ping.html
ping Command Package Class
/**
*
* @author seaboat
* @date 2016-09-25
* @version 1.0
* <pre><b>email: </b>849586227@qq.com</pre>
* <pre><b>blog: </b>http://blog.csdn.net/wangyangzhizhou</pre>
* <p>ping command packet.</p>
*/
public class PingPacket extends MySQLPacket {
// payload length is 1,packet id is 0,payload is 0e
public static final byte[] PING = new byte[] { 1, 0, 0, 0, 14 };
@Override
public int calcPacketSize() {
return 1;
}
@Override
protected String getPacketInfo() {
return "MySQL Ping Packet";
}
}
Source download: http://xiazai.ofstack.com/201701/yuanma/mysql-protocol-master (ofstack.com).rar
Thank you for reading, I hope to help you, thank you for your support on this site!