【发布时间】:2021-09-06 04:16:19
【问题描述】:
//pseudo code - actual code in c++
Process P1 code:
func handle_close() {
print "close";
}
func sayhello() {
print "hello";
}
func writeonsocketforP2() {
write(fd, somedata, somedata_sz);
}
func WriteToP2() {
count = 0;
while (count++ != 1000000) writeonsocketforP2();
sayhello();
}
考虑场景:
- 进程 P1(单线程)和 P2 之间建立的套接字连接
- P1 在循环中从 WriteToP2 函数向 P2 的套接字写入大量数据
- P2 在 P1 仍在写入时发生故障,并且 P1 获得了套接字关闭事件并调用了关闭事件处理程序 handle_close..let 说这发生在计数为 1000 时
- handle_close 被调用后,控制是否会返回 while 循环并从计数 1001 继续 while 循环?
- 在 WriteToP2 的 while 循环中间套接字关闭后会调用 sayhello()
【问题讨论】:
-
@Scheff'sCat 是的..伪代码...c ++中应用程序的实际代码..已编辑以发表评论
标签: c++ sockets event-handling network-programming