微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

为什么我构造的COM_BINLOG_DUMP包被mysql忽略了?

如何解决为什么我构造的COM_BINLOG_DUMP包被mysql忽略了?

这是我的 C++ 代码

bool slave::request_dump(){
    int binlog_filename_len=binlog_filename.length();
    ssize_t         res;
    struct _COM_binlog_DUMP
    {
        unsigned char cmd;
        unsigned char binlog_pos[4];
        unsigned char flags[2];
        unsigned char serverid[4];
    } COM_binlog_DUMP;
    MysqL_PACKET_HEADER  mph = { 0 };
    mph.plen = 11 + binlog_filename_len;
    mph.psid = 0; 
    COM_binlog_DUMP.cmd = 0x12;
    memcpy(COM_binlog_DUMP.serverid,&serverid,sizeof(COM_binlog_DUMP.serverid));
    COM_binlog_DUMP.flags[0] = 0x00;
    COM_binlog_DUMP.flags[1] = 0x00;
    memcpy(COM_binlog_DUMP.binlog_pos,&binlog_pos,sizeof(COM_binlog_DUMP.binlog_pos));
    
    unsigned char packet[sizeof(mph)+sizeof(COM_binlog_DUMP)+binlog_filename_len];
    memcpy(packet,&mph,sizeof(mph));
    memcpy(packet+sizeof(mph),&COM_binlog_DUMP,sizeof(COM_binlog_DUMP));
    memcpy(packet+sizeof(mph)+sizeof(COM_binlog_DUMP),binlog_filename.c_str(),binlog_filename_len);
    
    res = write(this->MysqL.net.fd,packet,sizeof(packet));
    
    if ( res == (15 + binlog_filename_len) ) {
        return 1;
    } else {
        return 0;
    }
}

这是我从wireshark得到的信息。 数据包被MysqL拒绝并确定为忽略的未知记录。

0000   00 0c 29 93 09 eb 00 0c 29 d7 b0 64 08 00 45 00   ..).....)..d..E.
0010   00 53 5d f3 40 00 40 06 e6 56 c0 a8 3a 87 c0 a8   .S].@.@..V..:...
0020   3a 83 96 c0 0c ea 7b 30 17 d7 4a 9d 54 84 80 18   :.....{0..J.T...
0030   01 f5 de fa 00 00 01 01 08 0a f3 e8 cd 78 a4 2d   .............x.-
0040   ee b8 1b 00 00 00 12 9a 00 00 00 00 00 e7 03 00   ................
0050   00 6d 79 73 71 6c 2d 62 69 6e 2e 30 30 30 30 30   .MysqL-bin.00000
0060   33                                                3

有人可以帮我吗?提前致谢。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。