0

Please tell me the most painless way of porting WSAAsyncSelect() function to GCC...

Ryan
  • 1,451
  • 2
  • 27
  • 36
  • `WSAAsyncSelect` is specific to the Windows platform for which you can target GCC to under Cygwin or MinGW, you should specify OSX platform rather than the compiler. – Steve-o Apr 23 '11 at 05:59

3 Answers3

1

I believe you want to look at the select function

Community
  • 1
  • 1
Jay
  • 13,803
  • 4
  • 42
  • 69
  • 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
1

I use pselect function.

Vink
  • 1,019
  • 2
  • 9
  • 18
1

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.

Warren Young
  • 40,875
  • 8
  • 85
  • 101