It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center。
我需要举例说明一个用于单线程服务器的程序
在C(Linux Red Hut)中侦听多个端口?
如果使用一个插座?
最佳答案
不能绑定到多个端口,因此也不能侦听。每个端口需要使用一个套接字。
这样做应该不难。简单地bind(2)
多个套接字,listen(2)
在每个套接字上,并将它们添加到select(2)
循环中。
关于c - 服务器监听多个端口c,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7627581/
10-13 07:31