views:

66

answers:

2

Hi, on windows, is there any other option when programming network communication then using Winsock? There are many socket libraries for c++, are they all just winsock based?

A: 

There are other ways to program network communication, which don't use Winsock: for example, using the network file system (shared files), or using named pipes.

Software can also bypass Winsock (which is a Windows user-mode DLL) even for TCP/IP traffic, and instead interface directly with the kernel-mode drivers.

ChrisW
do the browsers use winsock? I am trying to monitor network traffic using LSP but it only works with winsock.
Roar
@Roar I don't know. Maybe you could use something else, like (I don't know) HttpFox, or WireShark.
ChrisW
@Roar - Internet Explorer uses WinInet instead of WinSock. Wireshark can capture WinInet traffic, though. If you are trying to capture data with your own app, look at WinPCap.
Remy Lebeau - TeamB
WinINet is built on top of WinSock. I would imagine the vast majority of user-mode networking code on Windows runs on top of WinSock.
Luke
+1  A: 

You can consider using boost::asio. Boost is really great and well designed. Many parts of it have come already into C++0x. You will need to statically link to a lib or dll (it is not a header only template library)

Winsock are the sockets for Windows taken over from BSD (with actually exactly the same API excepting for closesocket vs close and the initialization/termination of the subsystem). Not the Win API itself has a more modern API the WSAxxx functions. C++ is socket unaware until now that means in order to do networking you MUST use the OS API, thus Winsock. There is no other low level API.

If you are trying to monitor traffic why don't you use WinPCAP?

jdehaan
do you think its better to use winpcap then using LSP? i also need to modify it and block it. Not only on default ports like http 80 but also other.
Roar
I don't know LSP so well. WinPCAP might be an alternative for you, up to you to decide if it fullfils your needs or not. It is rather powerful and also the same API exists for Linux, thus you could write a tool for different OSes with the same codebase (like Wireshark does). There are so many aspects to consider. I don't know if you knew PCAP or not, I just wanted to point out an alternative. :-)
jdehaan
If you need to modify something in the data flow, then PCAP is not for you, it's only there to capture, not to modify or block traffic.
jdehaan