开发者

MacOSX Socket Programming without run loop

开发者 https://www.devze.com 2023-04-08 06:59 出处:网络
Currently there is a CSNetwork class and a stream class with a run loop to recieve. Due to some reason I do not wish to have callbacks in my socket class code.

Currently there is a CSNetwork class and a stream class with a run loop to recieve. Due to some reason I do not wish to have callbacks in my socket class code. I am looking for the following - simple connect API - simple send API - simple rec开发者_开发百科v API - simple getHostbyName equivalent without a callback

Can someone help


In short, don't do that unless you really need the code to be portable. If you do, then use the pure POSIX APIs, of which there are about a zillion examples and sites available for reference.

You'll be far better off sticking with the higher level, callback based, APIs using run loops and/or queues. Less code. Easier to maintain. More efficient (in that it is better integrated with the platform).

If you still think you need to go the route of no callbacks, explain why. Keep in mind that synchronous code is just asynchronous code that blocks waiting for a callback....

0

精彩评论

暂无评论...
验证码 换一张
取 消