Originally Posted by
Ni3ls
If have been trying it for a while now, but I cant get it working. What I did.
It compiles with a lot of errors and I cant start a server
Code:
gsc_utils.cpp:1163: error: ‘BOOL’ does not name a type
gsc_utils.cpp: In function ‘int isValidAddress(const char*)’:
gsc_utils.cpp:1206: error: ‘isValidRange’ was not declared in this scope
gsc_utils.cpp: In function ‘char* sendCommand(char*, int, char*)’:
gsc_utils.cpp:1217: error: ‘SOCKET’ was not declared in this scope
gsc_utils.cpp:1217: error: expected ‘;’ before ‘Socket’
gsc_utils.cpp:1218: error: ‘WSADATA’ was not declared in this scope
gsc_utils.cpp:1218: error: expected ‘;’ before ‘WSAData’
gsc_utils.cpp:1219: error: ‘SOCKADDR_IN’ was not declared in this scope
gsc_utils.cpp:1219: error: expected ‘;’ before ‘server’
gsc_utils.cpp:1235: error: ‘server’ was not declared in this scope
with a lot more "not declared" errors
Those errors are because they are only used by Windows.
You should look at examples how to setup a UDP client on Linux.
http://www.linuxhowtos.org/C_C++/socket.htm
http://www.binarytides.com/programmi...ckets-c-linux/
If you need more help try googling 'linux c udp socket'.
Edit: there is also a simpler way to validate the IP address:
http://stackoverflow.com/questions/7...p-address-in-c
PHP Code:
#include <arpa/inet.h>
bool isValidIpAddress(char *ipAddress)
{
struct sockaddr_in sa;
int result = inet_pton(AF_INET, ipAddress, &(sa.sin_addr));
return result != 0;
}