windows 我如何用这个 SOCKET 调用 Poll()?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4938884/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I call Poll() with this SOCKET?
提问by T.T.T.
SOCKET server = socket(PF_INET,SOCK_STREAM, 0);
bind(server, 7.7.7.7, sizeof(7.7.7.7) );
listen(server, 0);
server.Poll(1, SelectMode.SelectRead);
error C2228: left of '.Poll' must have class/struct/union type
错误 C2228:“.Poll”的左侧必须具有类/结构/联合类型
The IP is not the same but the 3 functions work correctly creating a socket that the server can listen to and send data, to the client.
IP 不相同,但 3 个函数正常工作,创建一个套接字,服务器可以侦听该套接字并向客户端发送数据。
I would like to poll the client, using this example but in C++.
Which object or structure can I use here with Poll()?
我可以在 Poll() 中使用哪个对象或结构?
采纳答案by syllogism
回答by Remy Lebeau
In C#, Socket
is a class type, and has a Poll()
method.
在 C# 中,Socket
是一个类类型,并且有一个Poll()
方法。
In C++, SOCKET
is a handle type, not a class type, so there is no Poll()
method available. You need to use the select()
function.
在C++中,SOCKET
是句柄类型,不是类类型,所以没有Poll()
可用的方法。您需要使用该select()
功能。