#include <iostream>
#include <winsock2.h>
using namespace std;
int main(int argc, char ** argv)
{    
    if(argc != 2)
    {
        cout << "Brug: " << argv[0] << " <IP address|hostnavn>" << endl;
        return 0;
    }
    WSADATA wsaData;
    int err = WSAStartup(MAKEWORD(2,2),&wsaData);
    if(err != 0)
    {
        cerr << "Kunne ikke initialisere WinSock." << endl;
        return -1;
    }
    struct in_addr adr;
    struct hostent * entity;
    
    adr.S_un.S_addr = inet_addr(argv[1]);
    
    if(adr.S_un.S_addr == INADDR_NONE && string(argv[1]) != string("255.255.255.255"))
    {        
        entity = gethostbyname(argv[1]);
    }
    else    {
        
        entity = gethostbyaddr((char*)&adr,sizeof(adr),AF_INET);
    }
    
    if(entity == NULL)
    {
        switch(WSAGetLastError())
        {
            case WSAENETDOWN:
                cout << "Fejl i netværks komponenten." << endl;
                break;
            case WSAHOST_NOT_FOUND:
                cout << argv[1] << " blev ikke fundet." << endl;
                break;
            case WSATRY_AGAIN:
                cout << "Der skete en midlertidig fejl på navne serveren. Prøv igen senere." << endl;
                break;
            case WSANO_RECOVERY:
                cout << "Der skete en fejl på navne serveren." << endl;
                break;
            case WSANO_DATA:
                cout << argv[1] << " er et gyldigt navn men har ikke en IP adresse." << endl;
                break;
            case WSAEINPROGRESS:
                cout << "WinSock kan ikke processere dit kald." << endl;
                break;
        }
    }
    else
    {
        int i = 0;
        cout << "Officielt navn: " << entity->h_name << endl;
        while(entity->h_aliases[ i ])
        {
            cout << "Alias " << (i+1) << ": " << entity->h_aliases[ i ] << endl;
            i++;
        }
        i = 0;
        while(entity->h_addr_list[ i ])
        {
            cout << "IP adresse " << (i+1) << ": " << inet_ntoa(*((struct in_addr*)entity->h_addr_list[ i ])) << endl;
            i++;
        }
    }
    err = WSACleanup();
    if(err != 0)
    {
        cerr << "Kunne ikke release WinSock." << endl;
        return -1;
    }
    return 0;
}
Denne kode vil ikke compile og den er taget direkte fra artiklen. den giver følgende fejlmeddelelse:
------ Build started: Project: EatIT, Configuration: Debug Win32 ------
Compiling...
EatIT.cpp
c:\\documents and settings\\administrator\\dokumenter\\visual studio 2005\\projects\\remotebackop\\remotebackop\\eatit.cpp(27) : error C2678: binary '!=' : no operator found which takes a left-hand operand of type 'std::basic_string<_Elem,_Traits,_Ax>' (or there is no acceptable conversion)
        with
        [
            _Elem=char,
            _Traits=std::char_traits<char>,
            _Ax=std::allocator<char>
        ]
        c:\\programmer\\microsoft visual studio 8\\vc\\platformsdk\\include\\guiddef.h(197): could be 'int operator !=(const GUID &,const GUID &)'
        while trying to match the argument list '(std::basic_string<_Elem,_Traits,_Ax>, std::basic_string<_Elem,_Traits,_Ax>)'
        with
        [
            _Elem=char,
            _Traits=std::char_traits<char>,
            _Ax=std::allocator<char>
        ]
Build log was saved at "file://c:\\Documents and Settings\\Administrator\\Dokumenter\\Visual Studio 2005\\Projects\\RemoteBackOp\\RemoteBackOp\\Debug\\BuildLog.htm"
EatIT - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========