As an attempt at wrapping my head around udp sockets I\'ve tried to port the code from this tutorial page http://www.linuxhowtos.org/C_C++/socket.htm to winsock (running on
Well, I'm not sure if winsock2.h works the same way in Windows and Linux, but, in Windows, when you create the socket, you must set the protocol you're using, either TCP or UDP:
SOCKET sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
AF_INET = IPv4; SOCK_STREAM = Byte stream for TCP; IPPROTO_TCP = TCP Protocol.
For UDP (which i've never used before), according to MSDN it would be:
SOCKET sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
SOCK_DGRAM = Byte stream for UDP; IPPROTO_UDP = UDP Protocol.
That code would work in Windows. I guess in Linux it would be similar.