コード例 #1
0
ファイル: client.c プロジェクト: Sconso/Irc
void				be_client(char *ip, int port)
{
	t_socket		sock;
	fd_set			rdfs;
	char			*ask;
	char			*prompt;

	sock = init_connection(ip, port);
	while (1)
	{
		init_socks(sock, &rdfs);
		if (FD_ISSET(STDIN_FILENO, &rdfs))
			client_in(sock);
		else if (FD_ISSET(sock, &rdfs))
		{
			client_out(sock);
			ask = ft_strdup("/gp\n");
			ft_send(sock, ask);
			free(ask);
			prompt = get_message(sock);
			ft_putstr("\n");
			ft_putstr(prompt);
			free(prompt);
		}
	}
}
コード例 #2
0
ファイル: eplsvr.c プロジェクト: WayWingsDev/openrmd
static void *loop_thread(void *arg)
{
	eplsvr_t *ep = (eplsvr_t *)arg;

	int fds, i;
	struct epoll_event evs[EVENTS];

	while (1) {
		fds = epoll_wait(ep->eplfd, evs, EVENTS, -1);
		if (fds == -1 && errno != EINTR) {
			syslog(LOG_ERR, "epoll_wait(): %s", strerror(errno));
			//continue;
			exit(1);
		}

		for (i = 0; i < fds; i++) {
			if (evs[i].data.fd == ep->lsnfd)  /* client comming */
				client_in(ep);
			else if (evs[i].events & EPOLLIN) /* data comming */
				data_in(ep, evs[i].data.fd);
			else	/* error */
				client_out(ep, evs[i].data.fd);
		}
	}

	return NULL;
}