开发者

How can I get started with cross platform network programming?

开发者 https://www.devze.com 2023-03-24 04:57 出处:网络
I\'m thinking of purchasing this book to learn more on C/C++ networking programming: I was just wondering is there/do I need a windows equivalent book (I do plan to code on both OS\'). I\'m not sure

I'm thinking of purchasing this book to learn more on C/C++ networking programming:

I was just wondering is there/do I need a windows equivalent book (I do plan to code on both OS'). I'm not sure of the difference in the evolution regarding BSD sockets the windows.

I'm mainly buying this to eventually write code which will st开发者_StackOverflow中文版ream data between computers.


"Porting Socket Applications to Winsock"


Having done both, I'd definitely start out with the BSD version. Not only will you be learning something useful on both platforms (and others), but you'll have a better feel for what's really going on underneath.

I think the questions you need to ask yourself are:

  • How soon do you plan to add Windows to your network programming repertoire, AND
  • Do you want your code to be cross-platform

If you want your code to be cross-platform, I'd look at Boost or some other cross-platform network library to get you there quickly. If you are simply wanting to start out learning about network programming in general and then add Windows network programming specifically to your skillset, I'd start with the BSD API as you've planned and then get a resource for specifically doing this for Windows when you are ready. When I made the move from Linux to Windows I found it was worth the extra time to learn the Windows way of doing things.


Even though you can use Windows API to do socket programming, I would recommend you learning BSD sockets API (or POSIX sockets API) and used it in BOTH: Windows and Linux.

Windows has great support for BSD sockets API.

And you will greatly benefit from a single code base instead of coding twice the same features. Besides, BSD/POSIX API is also available in many other UNIX flavors (MAC OS X, HP/UP, AI/X, BSD, you name it).


For simple apps, BSD sockets will work just fine in Windows. But for the bells and whistles, I really recommend reading up on "native" winsock. Asynchronous sockets are really nice in GUI apps, and Overlapped I/O is just the bee's knees if you want high speed performance, without having to deal with threads (you can if you want to, but Windows will do it for you).

This is a good read.


There's Network Programming for MS Windows. I haven't read this yet, but will definitely do it as it looks very promising.


Don't spend your money yet - I haven't personally found a better guide on networking than Beej's. http://beej.us/guide/bgnet/

0

精彩评论

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