gochatai/pachi_py/pachi/network.c
/* Waits for a connection on the given socket, and returns the file descriptor.
 * Updates the client address if it is not null.
 * WARNING: the connection is not authenticated. As a weak security measure,
 * the connections are limited to a private network. */
Waits for a connection on the given socket, and returns the file descriptor.
Updates the client address if it is not null.
WARNING: the connection is not authenticated. As a weak security measure,
the connections are limited to a private network.
Waits for a connection on the given socket and returns the file descriptor . Updates the client address if it is not null . WARNING : the connection is not authenticated . As a weak security measure the connections are limited to a private network .
int
open_server_connection(int socket, struct in_addr *client)
{
	assert(socket >= 0);
	for (;;) {
		struct sockaddr_in client_addr;
		int sin_size = sizeof(struct sockaddr_in);
		int fd = accept(socket, (struct sockaddr *)&client_addr, (socklen_t *)&sin_size);
		if (fd == -1) {
			die("accept");
		}
		if (is_private(&client_addr.sin_addr)) {
			if (client)
				*client = client_addr.sin_addr;
			return fd;
		}
		close(fd);
	}
}
int open_server_connection ( int socket , struct in_addr * client ) { assert ( socket >= 0 ) ; for ( ; ; ) { struct sockaddr_in client_addr ; int sin_size = sizeof ( struct sockaddr_in ) ; int fd = accept ( socket , ( struct sockaddr * ) & client_addr , ( socklen_t * ) & sin_size ) ; if ( fd == -1 ) { die ( " " ) ; } if ( is_private ( & client_addr . sin_addr ) ) { if ( client ) * client = client_addr . sin_addr ; return fd ; } close ( fd ) ; } }
Waits for a connection on the given socket, and returns the file descriptor.
Waits for a connection on the given socket and returns the file descriptor .