Back again!
I've been doing some async socket programming with select() on windows,and it's been working quite well. However it开发者_开发问答's only scalable up to 1024 clients.Poll() is the way to get around that limitation, and I know it works on both linux and unix. But it doesn't work with a windows system correct?
I read about WsaPoll(), does it have the exact same functionality? What libraries would I have to link to in order to use it?
Can I increase the socket number safely in windows with FD_SETSIZE? My end program will be on a linux server. However I am testing on a windows system right now. Should I just swap my test machine over to a linux box? (probably going to anyway)
Otherwise what would you recommend to use with windows?
(sorry for all of the questions, I am doing research on my own, I promise =D)
Yes WSAPoll()
behaves like poll()
. You will need to use WSAGetLastError
to figure out what goes wrong. The error codes don't match up and depending on the WindowsSDK and your system version the posix codes may or may not be defined in the winsock2 header.
To use WSAPoll
you must include the winsock2.h and link to ws2_32.lib and run the application on Windows Vista/Server 2008 and up.
However having WSAPoll
in your code won't always stop it from compiling on Windows XP and you will instead get an error when you start your application.
If you don't intend to run your application on Windows then I recommend skipping the SDK, build, dll, and Windows version pain and setting up a Linux vm to develop on.
libevent will use the best available mechanism for event-driven programming on Windows, Linux, Solaris, OS X, and all the BSD derivatives.
On Windows, WSAAsyncSelect
should let you handle events from thousands of sockets in a single thread.
精彩评论