void NET_Shutdown (struct qw_connection *qwc) { if (qwc->netdata == 0) Sys_Error(qwc, "NET_Shutdown() called twice\n"); if (qwc->netdata->sockets[NS_CLIENT]) Sys_Net_DeleteSocket(qwc->netdata->sysnetdata, netdata->sockets[NS_CLIENT]); NET_ServerConfig(qwc, false); Sys_Net_Shutdown(qwc->netdata->sysnetdata); free(qwc->netdata); qwc->netdata = 0; }
static void QTVR_Thread(void *arg) { struct qtvr *qtvr; int r; char buf[128]; struct netaddr serveraddr; struct netaddr addr; struct SysNetData *netdata; struct SysSocket *socket; qtvr = arg; netdata = Sys_Net_Init(); if (netdata == NULL) { Com_Printf("QTVR_Thread: Sys_Net_Init failed.\n"); } else { if (!NET_StringToAdr(netdata, qtvr->server, &serveraddr)) { Com_Printf("QTVR_Thread: Unable to parse/resolve hoststring.\n"); } else { socket = Sys_Net_CreateSocket(netdata, serveraddr.type); if (socket == NULL) { Com_Printf("QTVR_Create: could not create socket.\n"); } else { Sys_Net_Send(netdata, socket, qtvr->request, strlen(qtvr->request), &serveraddr); while (!qtvr->quit) { Sys_Net_Wait(netdata, socket, 50000); if ((r = Sys_Net_Receive(netdata, socket, buf, sizeof(buf) - 1, &addr)) > 0) { buf[r] = 0; Sys_Thread_LockMutex(qtvr->mutex); qtvr->retval = strdup(buf); if (qtvr->retval == NULL) qtvr->status = QTVR_ERROR; else qtvr->status = QTVR_REPLY_RECIEVED; Sys_Thread_UnlockMutex(qtvr->mutex); break; } } Sys_Net_DeleteSocket(netdata, socket); } } Sys_Net_Shutdown(netdata); } if (qtvr->status != QTVR_REPLY_RECIEVED) qtvr->status = QTVR_ERROR; }
static void ServerScanner_Thread_Deinit(struct ServerScanner *serverscanner) { Sys_Net_Shutdown(serverscanner->netdata); }