Please tell me the most painless way of porting WSAAsyncSelect() function to GCC...
3 Answers
-
Thanks for the help, Vink and Jay! If it is not too much to ask, can you please provide some kind of example? I tried to compare arguments of pselect() and WSAAsyncSelect() and took a look at some examples and now I'm totally lost... – Ryan Apr 25 '11 at 06:36
While select()
and pselect()
may work for your application, they are very much not the same thing as WSAAsyncSelect()
. Those functions let you do controlled blocking on an otherwise non-blocking socket, or collection of sockets. The same goes for poll()
.
Winsock's asynchronous sockets, on the other hand, do not block, ever. There's also the large matter of async notifications, which your code doubtless depends on.
I do not believe there are any native APIs on OS X that provide similar behavior. However, it's possible to build up such a thing. A little Googling turned up CocoaAsyncSocket.
If you would rather not depend on third-party libraries, I suggest building up something on top of Cocoa's CFSocket, as the CocoaAsyncSocket developers did, if you will be porting over a GUI program, rather than dig down to core functions like select()
. There's something to be said for using a single development framework for everything.
If you need your code to be cross-platform, the wxWidgets library has the wxSockets* class hierarchy, which emulates the Winsock async socket mechanism. Overall, wxWidgets is structured much like MFC, which eases porting if you're familiar with that.

- 40,875
- 8
- 85
- 101