📄 connect.h
字号:
/** @file connect.h define the connection method to other daemon */#ifndef CONNECT_H#define CONNECT_H#include "config.h"#include "debug.h"#include "simple_list.h"#include <sys/socket.h>#include <sys/types.h>#include <netinet/in.h>#define CO_NOCONNECT 0#define CO_COWAITING 1#define CO_COINPROGRESS 2#define CO_CONNECT 3#define CO_HNOTDONE 1#define CO_DONE 2/** define the state of file descriptor for a daemon */typedef struct SockInfo { int cofd; /**< file descriptor used during connection to other daemon */ int costate; /**< state during connection to other daemon (to avoid double connection) */ int hstate; /**< causal information received or not */ int fd; /**< final file descriptor used when the connection is established */ struct sockaddr_in addr; /**< address of a connecting peer */ char * buf; /**< receive here the information of the other peer */ unsigned int size; /**< size of buf */} SockInfo;/** get socket of connecting people * @param readset : set of socket to read * @param max : mask for select * @return new mask for select */int inline getconnectingfdset(fd_set * readset, int max);/** function called to connect to an other peer * @param mpipeer : tab of all peer socket infos * @param rank : rank of the process to connect to * @return void */void on_connect(SockInfo mpipeer[], int rank);/** function called to finish the connection processing * @param mpipeer : tab of all peer socket infos * @param rank : rank of the process to connect to * @return void */void on_connected(SockInfo mpipeer[], int rank);/** function used when other process try to connect to ourself * @param scon : listening socket descriptor * @return */int on_accept(int scon);/** function called to finish an accept sequence * @param s : socket to other peer * @param mpipeer : tab of all peer socket infos * @param myrank : rank of the local mpi process * @return 0 if no connection reseolved, 1 else */int inline on_accepted(SockInfo mpipeer[], fd_set *readset);/** Initialize the sockets informations table of all mpi peer * @param np: size of MPI world * @param mr: my rank * @return the array of SockInfo for each mpi peer */SockInfo* initMpipeer(int np, int mr);/** parse the argument giving address of other peer * @param nodeListArray : table of address of other peer * @param mpipeer : socket infos of other peer * @return void */void parse_config_array(struct sockaddr_in *nodeListArray, SockInfo * mpipeer );/** launch the connection to one mpi peer * @param mpipeer: the array of peers * @param rank : rank of the process to connect to * @return void */void init_connect_to_one_MPI(SockInfo *mpipeer, int rank);/** initialize connection to all peer * @param mpipeer : the array of peers * @param mrank : rank of local mpi process * @return void */void init_connect_to_MPI(SockInfo *mpipeer, int mrank);/** called when one peer has broken connection * @param rank : rank of the disconnected peer * @param mpipeer : socket infos of all peer * @return void */void on_mpipeer_disconnect (int rank, SockInfo * mpipeer);/** close all sockets to other peer * @param mpipeer : socket infos of all peer * @param sizeofmpipeer : size of the mpipeer table * @return void */void close_all_daemon_sockets (SockInfo * mpipeer);/** initializes a listen socket on the specified port * @param listenPort: the port to listen to * @return the socket */int initListenSock(int listenPort);#endif /* CONNECT_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -