static void sendOption(int sd, char *option) /* If option exists send it down socket. */ { if (optionExists(option)) { char buf[256]; safef(buf, sizeof(buf), "%s %s", option, optionVal(option, NULL)); netSendString(sd, buf); } }
void returnList(int socket) /* Send list of all things tracked down socket. */ { struct tracker *tracker; char buf[256]; int timeDiff; safef(buf, sizeof(buf), "#IP_ADDRESS\thits\ttime\tmax\tcurrent"); netSendString(socket, buf); for (tracker = trackerList; tracker != NULL; tracker = tracker->next) { timeDiff = now - tracker->lastAccess; safef(buf, sizeof(buf), "%s\t%d\t%d\t%d\t%d", tracker->name, tracker->accessCount, timeDiff, tracker->maxDelay, calcDelay(tracker)); if (!netSendString(socket, buf)) break; } netSendString(socket, ""); }
int botDelayTime(char *host, int port, char *botCheckString) /* Figure out suggested delay time for ip address in * milliseconds. */ { int sd = netMustConnect(host, port); char buf[256]; netSendString(sd, botCheckString); netRecieveString(sd, buf); close(sd); return atoi(buf); }
void listAll() /* Ask server for info on all IP addresses. */ { int socket = netMustConnect(host, port); char buf[256], *s; netSendString(socket, "?"); for (;;) { s = netGetString(socket, buf); if (s == NULL || s[0] == 0) break; printf("%s\n", buf); } close(socket); }
void queryServer(char *ip, int count) /* Query bottleneck server - just for testing. * Main query is over ip port. */ { int i; for (i=0; i<count; ++i) { int socket = netMustConnect(host, port); char buf[256], *s; netSendString(socket, ip); s = netGetString(socket, buf); if (s == NULL) errAbort("Shut out by bottleneck server %s:%d", host, port); printf("%s millisecond delay recommended\n", s); close(socket); } }
void serverStop() /* Send stop message to server. */ { int sd = netMustConnect(host, port); netSendString(sd, "stop"); }