Exemplo n.º 1
0
		CNetManager::CNetManager(INetCallback* handler, u32 port, const SNetParams& params) :
			pHandler(handler), netIterations(10000), netParams(params), verbose(0),
			globPacketRelay(false), connectionStatus(EICS_PENDING)
		{
			if (enet_initialize() != 0)
				std::cout << "irrNetLite: An error occurred while initializing ENet.\n";

			connectionStatus = setUpServer(port) ? EICS_ESTABLISHED : EICS_FAILED;
		}
Exemplo n.º 2
0
int main(int argc, char *argv[]) {
	char* server_name;
	int server_port;
	handleInput(argc, argv, &server_name, &server_port);

	int server_fd = setUpServer(server_port);

	while (1) {
		//accept
		printf("Waiting for client connection..\n");
		int sock_fd = accept(server_fd, (struct sockaddr *) NULL, NULL);
		printf("Connection established. Start chatting!\n");
		
		//date for select
		fd_set set;
		FD_ZERO(&set);
		int max_fd = sock_fd + 1;
		struct timeval timeout;
		timeout.tv_sec = TIMEOUT_SECS;
		timeout.tv_usec = 0;

		while (1) {
			FD_SET(STDIN_FILENO, &set);
			FD_SET(sock_fd, &set);
			if (select(max_fd, &set, NULL, NULL, &timeout) == -1) {
				perror("select failed");
				exit(1);
			}

			char msg_buf[BUFFER_SIZE];
			memset(&msg_buf, 0, sizeof(msg_buf));
			if (FD_ISSET(STDIN_FILENO, &set)) {
				if (!handleOutgoingMsg(sock_fd, msg_buf, server_name)) {
					printf("Closing server..\n");
					free(server_name);
					exit(0);
				}
			}
			if (FD_ISSET(sock_fd, &set)) {
				if (!handleIncomingMsg(sock_fd, msg_buf)) {
					printf("Connection ended.\n");
					break;
				}
			}
		}
	}
	return 0;
}
Exemplo n.º 3
0
int main(int argc, char *argv[])
{
    setUpServer(argc, argv); //start the server
    
    memset((char *) &fd, 0, sizeof(fd)); //clear out the fd
    clearUsers();   //clear out the user list
    
    while (1) //infinite loop
    {
        connectionWaiting();
    } 
    
    close(sockfd);
    
    return 0; //we never get here
}
Exemplo n.º 4
0
Shortcut::Shortcut(int argc, char* argv[]): QMainWindow(0){
    QDir::addSearchPath("icons",RegistryEditor::getShortcutAppPath() + "/graphic");
    shortcutList = new ShortcutList();
    QIcon icon = QIcon("icons:logo.png");
    interaction = new Interaction(this, icon);

    if(argc == 2){
        QString path = argv[1];
        // if the second argument is -removeAll then clean the data
        if (path.compare("-removeAll") == 0){
            shortcutList->removeAll();
        }else
            stealthInteraction(path);

        return;
    }


    // the GUI works so run the server,
    createWindow();
    setUpServer();
}