Home > Database > Mysql Tutorial > Detailed ping command package and analysis of mysql protocol

Detailed ping command package and analysis of mysql protocol

黄舟
Release: 2017-03-07 14:01:13
Original
1827 people have browsed it

git

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

Overview

The mysql client can use the ping command to check the status of the server. Normally, an ok packet will be returned.

mysql communication message structure

##string payloadMessage body, the length is the previously specified payload length
Type Name Description
int<3> payload length Stored according to the least significant byte first, 3-byte payload and 1-byte sequence number combination Into the message header
int<1> sequence number
ping command package

Payload

1              [0e] COM_PING
Copy after login

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 class="brush:php;toolbar:false"><b>email: </b>849586227@qq.com
*
<b>blog: </b>//m.sbmmt.com/;/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";
    }

}
Copy after login
The above is the detailed content of the ping command package and analysis of the mysql protocol. For more related content, please pay attention to the PHP Chinese website (m.sbmmt.com)!



Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template