[C++] How to use Winsock to send stuff with UDP?
Moderator: General Moderators
[C++] How to use Winsock to send stuff with UDP?
I'm learning C++ and I'm wanting to send some data using UDP with winsock. All the tutorials I've found are either insanely complex or are for TCP. So, I'm asking here.
There's a short example at http://msdn2.microsoft.com/en-us/library/ms740148.aspx
It doesn't want to compile. I'm using Dev-C++ and I've included the following things (which Dev-C++ has):
I'm given the following errors upon compiling:
Code: Select all
#include <iostream>
#include <windows.h>
#include <winsock2.h>Code: Select all
[Linker error] undefined reference to `WSAStartup@8'
[Linker error] undefined reference to `socket@12'
[Linker error] undefined reference to `htons@4'
[Linker error] undefined reference to `inet_addr@4'
[Linker error] undefined reference to `sendto@24'
[Linker error] undefined reference to `closesocket@4'
[Linker error] undefined reference to `WSACleanup@0'
ld returned 1 exit status- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
toasty2 wrote:[Linker error] undefined reference to `WSAStartup@8'
http://msdn2.microsoft.com/en-us/library/ms742213.aspx wrote:WSAStartup
The WSAStartup function initiates use of the Winsock DLL by a process
[...]
Requirements
[...]
Library Use Ws2_32.lib.