/** ** Receive reply from Meta Server ** ** @param reply Text of the reply ** ** @return error or number of bytes */ int RecvMetaReply(char **reply) { if (NetSocketReady(MetaServerFildes, 5000) == -1) { return -1; } // FIXME: Allow for large packets char buf[1024]; int n = NetRecvTCP(MetaServerFildes, &buf, 1024); char *p = new char[n + 1]; if (!p) { return -1; } // We know we now have the whole command. // Convert to standard notation buf[n - 1] = '\0'; buf[n - 2] = '\n'; strcpy(p, buf); *reply = p; return n; }
int HasDataToRead(int timeout) { return NetSocketReady(socket, timeout); }