完成端口怎么老有序地改变io_operation啊,比如说一个线程来说,我要让它收到完成动作为read完成,write完成,write完成,write完成,read完成,怎么来操作啊?
如果是写法如下:
if(io_operation==read)
{
io_operation=write;
wsasend(); //收到写完成操作
wsasend(); //收到写完成操作
wsasend(); //收到写完成操作
}
if(io_operation==write)
{
io_operation=read;
wsarecv();
}我先从client发个包过来,收到读完成, 然后我要向client端写三个包.(假如我定义的缓冲区大小有限,数据大要要分包,因此要多发)然后再从client端读数据.为什么这样写会乱套啊?应该怎么来写呢?
如果是写法如下:
if(io_operation==read)
{
io_operation=write;
wsasend(); //收到写完成操作
wsasend(); //收到写完成操作
wsasend(); //收到写完成操作
}
if(io_operation==write)
{
io_operation=read;
wsarecv();
}我先从client发个包过来,收到读完成, 然后我要向client端写三个包.(假如我定义的缓冲区大小有限,数据大要要分包,因此要多发)然后再从client端读数据.为什么这样写会乱套啊?应该怎么来写呢?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货