gochatai/pachi_py/pachi/network.c
/* Open a connection on the given socket/port.
 * Act as server if the port doesn't contain a hostname,
 * as a client otherwise. If socket < 0 or in client mode,
 * create the socket from the given port and update socket.
 * Block until the connection succeeds.
 * Return a file descriptor for the new connection. */
Open a connection on the given socket/port.
Act as server if the port doesn't contain a hostname,
as a client otherwise. If socket < 0 or in client mode,
create the socket from the given port and update socket.
Block until the connection succeeds.
Return a file descriptor for the new connection.
Open a connection on the given socket / port . Act as server if the port doesn ' t contain a hostname as a client otherwise . If socket < 0 or in client mode create the socket from the given port and update socket . Block until the connection succeeds . Return a file descriptor for the new connection .
static int
open_connection(struct port_info *info)
{
	int conn;
	char *p = strchr(info->port, ':');
	if (p) {
		for (int try = 1;; ) {
			conn = open_client_connection(info->port);
			if (conn >= 0) break;
			sleep(try);
			if (try < MAX_WAIT) try++;
		}
		info->socket = conn;
	} else {
		if (info->socket < 0)
			info->socket = port_listen(info->port, MAX_CONNEXIONS);
		conn = open_server_connection(info->socket, NULL);
	}
	return conn;
}
static int open_connection ( struct port_info * info ) { int conn ; char * p = strchr ( info -> port , ' ' ) ; if ( p ) { for ( int try = 1 ; ; ) { conn = open_client_connection ( info -> port ) ; if ( conn >= 0 ) break ; sleep ( try ) ; if ( try < MAX_WAIT ) try ++ ; } info -> socket = conn ; } else { if ( info -> socket < 0 ) info -> socket = port_listen ( info -> port , MAX_CONNEXIONS ) ; conn = open_server_connection ( info -> socket , NULL ) ; } return conn ; }
Open a connection on the given socket/port.
Open a connection on the given socket / port .