All pastes #1013930 Raw Edit

Mine

public cpp v1 · immutable
#1013930 ·published 2008-05-10 18:21 UTC
rendered paste body
// Preprocessor Definitions/Declarations.#ifndef WIN32_LEAN_AND_MEAN#define WIN32_LEAN_AND_MEAN#endif// Files to include#include <windows.h>#include <winsock2.h>#include <stdio.h>// Custom Preprocessor Definitions/Declarations.#define MAX_CLIENTS 5int main(){    // Definitions/Declarations.    int iResult; // Error Checking & Creation of WinSock.    WSAData wsaData; // Stores Information about WinSocket.    sockaddr_in nraddr; // The address structure for our TCP socket.            // Initialize Winsock and check for errors.    iResult = WSAStartup(MAKEWORD(2,2), &wsaData); // Initialize.    if (iResult != 0) { // Check for errors.        printf("WSAStartup failed: %d\n", iResult); // Print Error Number.        return 1; // Exit Application.    }        // Create and bind the socket.    SOCKET nrserv = socket (AF_INET, SOCK_STREAM, 0); // Create socket nrserv.        nraddr.sin_family = AF_INET; // Address Family: Internet.    nraddr.sin_port = hton(5701); // Assign default port to the socket.    nraddr.sin_addr.s_addr = htonl (INADDR_ANY); // Set no destination.        if(bind(nrserv,(LPSOCKADDR) &nraddr, sizeof(nraddr)) == SOCK_ERROR) // Bind & check for errors.    { // If error.        WSACleanup(); // Unload WinSock.        return 1; // Terminate Application.    }        return 0;}