ExtFunc void CloseRobot(void) { RemoveEventGen(&robotGen); if (robotProcess > 0) RobotCmd(1, "Exit\n"); fclose(toRobot); close(fromRobotFd); }
ExtFunc void CloseNet(void) { MyEvent event; if (sock >= 0) { if (!lostConn) { SendPacket(NP_endConn, 0, NULL); if (isServer) { while (!lostConn) WaitMyEvent(&event, EM_net); } else { while (!gotEndConn) WaitMyEvent(&event, EM_net); SendPacket(NP_byeBye, 0, NULL); } } close(sock); sock = -1; } if (netGen.next) RemoveEventGen(&netGen); }