I’m writing a simple program that listen over the network for incoming tcp/udp packets and retrieve data from them. I need also to parse the packet header for getting the sequence number, etc. I’m running windows7 and VC++ 2010.
Obviously i need a packets generator and i want to use the loopback adress so the sender and receiver be on the same machine.
Since i’m beginner in c++ network programming, i need a little help to figure out how to proceed.
Should i build my own tcp/udp generator? if yes, must i use RAW sockets or a higher level api would be enough (possibility to get the ip header). If no, which generator should use?
What technologie should i use for the receiver? i was looking at the boost::asio and winsock2.h. But since i don’t have so much time to discover both of them, Could somebody tell me what should i do.
Thank you in front for your help.
Best regards.
If you’re using winsock, then you don’t have to worry about parsing the IP header at all. Winsock (well the OS really) does all that for you. There is no need to use raw sockets (I have done network programming for 20+ years and have never once needed to use a raw socket!).
So for a client, the functions you want are
socket/connect/send/recv. For a server,socket/bind/listen/accept/recv/send.