Results 1 to 10 of 21

Thread: My new sendCommand function with libcod (windows)

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #7
    Global Mossaderator Mitch's Avatar
    Join Date
    Nov 2012
    Posts
    654
    Thanks
    204
    Thanked 450 Times in 305 Posts
    Quote Originally Posted by Ni3ls View Post
    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_INETipAddress, &(sa.sin_addr));
        return 
    result != 0;

    Last edited by Mitch; 9th January 2016 at 15:35.

  2. The Following User Says Thank You to Mitch For This Useful Post:

    Ni3ls (9th January 2016)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •