return NULL; }  sockOpt.option = PR_SockOpt_Reuseaddr; sockOpt.value.reuse_addr = PR_TRUE; if ( PR_SetSocketOption(listenSocket, &sockOpt) == PR_FAILURE) { if (debug_mode) printf("\tServer error setting socket option: OS error %d\n", PR_GetOSError()); else failed_already=1; PR_Close(listenSocket);
ServerSetup(void){    PRFileDesc *listenSocket;    PRNetAddr serverAddr;    PRThread *WorkerThread;    if ( (listenSocket = PR_NewTCPSocket()) == NULL) {        if (debug_mode) printf("\tServer error creating listen socket\n");		else failed_already=1;        return NULL;    }    memset(&serverAddr, 0, sizeof(PRNetAddr));    serverAddr.inet.family = PR_AF_INET;    serverAddr.inet.port = PR_htons(PORT);    serverAddr.inet.ip = PR_htonl(PR_INADDR_ANY);    if ( PR_Bind(listenSocket, &serverAddr) == PR_FAILURE) {        if (debug_mode) printf("\tServer error binding to server address: OS error %d\n",                PR_GetOSError());		else failed_already=1;        PR_Close(listenSocket);        return NULL;    }    if ( PR_Listen(listenSocket, 128) == PR_FAILURE) {        if (debug_mode) printf("\tServer error listening to server socket\n");		else failed_already=1;        PR_Close(listenSocket);        return NULL;    }    /* Create Clients */    workerThreads = 0;    workerThreadsBusy = 0;    workerThreadsLock = PR_NewLock();    WorkerThread = PR_CreateThread(                      PR_SYSTEM_THREAD,                      WorkerThreadFunc,                      listenSocket,                      PR_PRIORITY_NORMAL,                      ServerScope,                      PR_UNJOINABLE_THREAD,                      STACKSIZE);    if (!WorkerThread) {        if (debug_mode) printf("error creating working thread\n");        PR_Close(listenSocket);        return NULL;    }    PR_AtomicIncrement(&workerThreads);    if (debug_mode) DPRINTF("\tServer created primordial worker thread\n");    return listenSocket;}