Hello, noobie here.

Currently learning winsock programming from MSDN Microsoft pages. In their example, they use the following:

Code:
// Resolve the local address and port to be used by the server
iResult = getaddrinfo(NULL, DEFAULT_PORT, &hints, &result);
if (iResult != 0) {
    printf("getaddrinfo failed: %d\n", iResult);
    WSACleanup();
    return 1;
}
and

Code:
    iResult = bind( ListenSocket, result->ai_addr, (int)result->ai_addrlen);
    if (iResult == SOCKET_ERROR) {
        printf("bind failed with error: %d\n", WSAGetLastError());
        freeaddrinfo(result);
        closesocket(ListenSocket);
        WSACleanup();
        return 1;
    }
My problem here is, in the first code, the program prints "iResult" if there was to be an error whereas the second code prints WSAGetLastError(). Why is it like this? Also when is it appropriate to do one over the other?

Complete Source Code found here:
Complete Winsock Server Code (Windows)

Kind regards.