int PHandler_TcpGetData(int pID, int connection, void* buf, int size ) { int len; pluginTcpClientSocket_t* ptcs = &pluginFunctions.plugins[pID].sockets[connection]; if(ptcs->sock < 1){ Com_PrintWarning("Plugin_TcpGetData: called on a non open socket for plugin ID: #%d\n", pID); return -1; } len = NET_TcpClientGetData(ptcs->sock, buf, size); if(len == -1) { ptcs->sock = -1; } return len; }
/* =============== NET_ReceiveData Receives a TCP datastream return values: 2: Got new data + Connection okay 1: Got no data + Connection okay -1: Got no data + Connection closed -2: Got new data + Connection closed ================ */ int NET_TcpReceiveData( int sock, msg_t* msg) { int len = msg->maxsize - msg->cursize; int ret; ret = NET_TcpClientGetData( sock, msg->data + msg->cursize, &len); if(ret < 0 && len > 0) { msg->cursize += len; return -2; } if(ret < 0 && len < 1) { return -1; } if(len > 0) { msg->cursize += len; return 2; } return 1; }