Chroma
Chroma

Reputation: 23

Winsock alternative (no, not WinPCAP)

Are there any viable alternatives to Winsock for C++? The reason I need of is because Winsock's raw sockets are not behaving properly (no, this is not fixable, don't waste your time asking) and WinPCAP can only monitor network traffic, not actually receive packets. I need something that can receive complete packets including any IP, UDP, TCP headers, etc. Does such a thing exist, and if not, why not?

Upvotes: 1

Views: 2697

Answers (2)

casablanca
casablanca

Reputation: 70691

WinPCAP can only monitor network traffic, not actually receive packets

Monitoring network traffic is equivalent to receiving packets. That's exactly what tools such as Wireshark do: read off your network card and reconstruct packet boundaries.

I need something that can receive complete packets including any IP, UDP, TCP headers, etc.

This is very much possible using the Winsock API. Have a look at the WSAIoctl function, specifically the SIO_RCVALL option - enabling this option will deliver ALL packets received on an interface to your socket. And these are raw IP packets starting with the IP header.

Upvotes: 6

Anthony
Anthony

Reputation: 12387

You could look at Boost.Asio. C++ cross-platform IO library. Support for UDP, TCP and ICMP.

Upvotes: 1

Related Questions