- if (buf[0] == '1') {
- while (CtdlIPC_chat_recv(ipc, buf), strcmp(buf, "000")) {
- printf("%s\n", buf);
- alarm(watchdog); /* Kick the watchdog timer */
- }
- } else if (buf[0] == '4') {
- do {
- if (fgets(buf, sizeof buf, stdin) == NULL)
- strcpy(buf, "000");
- if (!IsEmptyStr(buf))
- if (buf[strlen(buf) - 1] == '\n')
- buf[strlen(buf) - 1] = 0;
- if (!IsEmptyStr(buf))
- if (buf[strlen(buf) - 1] == '\r')
- buf[strlen(buf) - 1] = 0;
- if (strcmp(buf, "000"))
- CtdlIPC_chat_send(ipc, buf);
-
- FD_ZERO(&read_fd);
- FD_SET(ipc->sock, &read_fd);
- ret = select(ipc->sock+1, &read_fd, NULL, NULL, &tv);
- err = errno;
- if (err!=0)
- printf("select failed: %d", err);
-
- if (ret == -1) {
- if (!(errno == EINTR || errno == EAGAIN))
- printf("select failed: %d", err);
- return 1;
- }
+ fprintf(stderr, "%s\n", buf);
+ serv_puts(buf);
+ serv_gets(buf);
+ fprintf(stderr, "%s\n", buf);