client/src/unifycr.c
static int unifycr_init_socket(int proc_id, int l_num_procs_per_node, \
		int l_num_del_per_node) {
	int rc = -1;

	int len;
	int result;

	client_sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
	if (client_sockfd < 0)
		return -1;

	struct sockaddr_un serv_addr;
	memset(&serv_addr, 0, sizeof(serv_addr));
	serv_addr.sun_family = AF_UNIX;
	char tmp_path[GEN_STR_LEN] = {0};


	int nprocs_per_del;
	if (l_num_procs_per_node%l_num_del_per_node == 0) {
		nprocs_per_del = l_num_procs_per_node/l_num_del_per_node;
	} else {
		nprocs_per_del = l_num_procs_per_node/l_num_del_per_node + 1;
	}

	/*which delegator I belong to*/
	sprintf(tmp_path, "%s%d", SOCKET_PATH,\
			proc_id/nprocs_per_del);

	strcpy(serv_addr.sun_path, tmp_path);
	len = sizeof(serv_addr);
	result = connect(client_sockfd, (struct sockaddr *)&serv_addr, len);

	/* exit with error if connection is not successful */
	if(result == -1) {
		rc = -1;
		return rc;
	}

	int flag = fcntl(client_sockfd, F_GETFL);
	fcntl(client_sockfd, F_SETFL, flag|O_NONBLOCK);
	cmd_fd.fd = client_sockfd;
	cmd_fd.events = POLLIN|POLLHUP;
	cmd_fd.revents = 0;

	return 0;

}
/**
* initialize the client-side socket
* used to communicate with the server-side
* delegators. Each client is serviced by
* one delegator.
* @param proc_id: local process id
* @param l_num_procs_per_node: number
* of ranks on each compute node
* @param l_num_del_per_node: number of server-side
* delegators on the same node
* @return success/error code
*/
initialize the client-side socket
used to communicate with the server-side
delegators. Each client is serviced by
one delegator.
initialize the client - side socket used to communicate with the server - side delegators . Each client is serviced by one delegator .
static int unifycr_init_socket(int proc_id, int l_num_procs_per_node, \
		int l_num_del_per_node) {
	int rc = -1;
	int len;
	int result;
	client_sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
	if (client_sockfd < 0)
		return -1;
	struct sockaddr_un serv_addr;
	memset(&serv_addr, 0, sizeof(serv_addr));
	serv_addr.sun_family = AF_UNIX;
	char tmp_path[GEN_STR_LEN] = {0};
	int nprocs_per_del;
	if (l_num_procs_per_node%l_num_del_per_node == 0) {
		nprocs_per_del = l_num_procs_per_node/l_num_del_per_node;
	} else {
		nprocs_per_del = l_num_procs_per_node/l_num_del_per_node + 1;
	}
	sprintf(tmp_path, "%s%d", SOCKET_PATH,\
			proc_id/nprocs_per_del);
	strcpy(serv_addr.sun_path, tmp_path);
	len = sizeof(serv_addr);
	result = connect(client_sockfd, (struct sockaddr *)&serv_addr, len);
	if(result == -1) {
		rc = -1;
		return rc;
	}
	int flag = fcntl(client_sockfd, F_GETFL);
	fcntl(client_sockfd, F_SETFL, flag|O_NONBLOCK);
	cmd_fd.fd = client_sockfd;
	cmd_fd.events = POLLIN|POLLHUP;
	cmd_fd.revents = 0;
	return 0;
}
static int unifycr_init_socket ( int proc_id , int l_num_procs_per_node , int l_num_del_per_node ) { int rc = -1 ; int len ; int result ; client_sockfd = socket ( AF_UNIX , SOCK_STREAM , 0 ) ; if ( client_sockfd < 0 ) return -1 ; struct sockaddr_un serv_addr ; memset ( & serv_addr , 0 , sizeof ( serv_addr ) ) ; serv_addr . sun_family = AF_UNIX ; char tmp_path [ GEN_STR_LEN ] = { 0 } ; int nprocs_per_del ; if ( l_num_procs_per_node % l_num_del_per_node == 0 ) { nprocs_per_del = l_num_procs_per_node / l_num_del_per_node ; } else { nprocs_per_del = l_num_procs_per_node / l_num_del_per_node + 1 ; } sprintf ( tmp_path , " " , SOCKET_PATH , proc_id / nprocs_per_del ) ; strcpy ( serv_addr . sun_path , tmp_path ) ; len = sizeof ( serv_addr ) ; result = connect ( client_sockfd , ( struct sockaddr * ) & serv_addr , len ) ; if ( result == -1 ) { rc = -1 ; return rc ; } int flag = fcntl ( client_sockfd , F_GETFL ) ; fcntl ( client_sockfd , F_SETFL , flag | O_NONBLOCK ) ; cmd_fd . fd = client_sockfd ; cmd_fd . events = POLLIN | POLLHUP ; cmd_fd . revents = 0 ; return 0 ; }
initialize the client-side socket
used to communicate with the server-side
delegators.
initialize the client - side socket used to communicate with the server - side delegators .
/*which delegator I belong to*/ /* exit with error if connection is not successful */