diff --git a/src/gausskernel/cbb/communication/comm_proxy/comm_proxy.cpp b/src/gausskernel/cbb/communication/comm_proxy/comm_proxy.cpp index e564fb438..a110d4b35 100644 --- a/src/gausskernel/cbb/communication/comm_proxy/comm_proxy.cpp +++ b/src/gausskernel/cbb/communication/comm_proxy/comm_proxy.cpp @@ -172,6 +172,15 @@ ssize_t comm_proxy_addr_recv(int sockfd, void *buf, size_t len, int flags) return comm_proxy_recv(sockfd, buf, len, flags); } +/* +function name: comm_proxy_close +description: The function is used to release the resources allocated + to the socket by the system. +arguments: The argument is the socket file descriptor to be closed. +return value: If the call is successful, return 0; otherwise, return - 1 and set errno. +note: none +contact tel: 18720816902 +*/ int comm_proxy_close(int fd) { SocketRequest req; @@ -223,6 +232,17 @@ int comm_proxy_close(int fd) return result.s_ret; } +/* +function name: comm_proxy_shutdown +description: The function is used to release the resources allocated + to the socket by the system. +arguments: The first argument is a descriptor used to identify a socket. + The second argument is used to describe which operations + are prohibited, which determines the behavior of the function. +return value: If the call is successful, return 0; otherwise, return - 1 and set errno. +note: none +contact tel: 18720816902 +*/ int comm_proxy_shutdown(int fd, int how) { SocketRequest req; @@ -277,6 +297,20 @@ int comm_proxy_shutdown(int fd, int how) return result.s_ret; } +/* +function name: comm_proxy_accept +description: This function extracts the first connection from the waiting connection queue of S, creates + a new socket interface similar to s and returns a handle. +arguments: The first argument is a socket descriptor, which listens for connection after comm_proxy_listen(). + The second argument is a optional pointer pointing to a buffer where the address of the + connection entity known to the communication layer is received. The actual format of the + addr argument is determined by the address family generated when the socket is created. + The third argument is a optional pointer, used together with addr, pointing to the integer + number with the length of addr address. +return value: The return value is a new socket descriptor, which represents a new connection with the client. +note: none +contact tel: 18720816902 +*/ int comm_proxy_accept(int sockfd, struct sockaddr* addr, socklen_t* addrlen) { SocketRequest req; @@ -361,6 +395,16 @@ int comm_proxy_accept4(int sockfd, struct sockaddr* addr, socklen_t* addrlen, in return comm_proxy_accept(sockfd, addr, addrlen); } +/* +function name: comm_proxy_connect +description: This function is used to establish a connection with a specified socket. +arguments: The first argument is used to identify an unconnected socket. + The second argument is a pointer to the sockaddr structure to socket will be connected. + The third argument is byte length of sockaddr structure. +return value: The return value is 0 if succeed, - 1 is returned for failure and error reason is stored in errno. +note: none +contact tel: 18720816902 +*/ int comm_proxy_connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen) { SocketRequest req; @@ -412,6 +456,16 @@ int comm_proxy_connect(int sockfd, const struct sockaddr *addr, socklen_t addrle return result.s_ret; } +/* +function name: comm_proxy_bind +description: This function binds a local address with a set of interfaces. +arguments: The first argument indicates the socket descriptor that has been established. + The second argument is a pointer to the sockaddr structure to socket. + The third argument is byte length of sockaddr structure. +return value: The return value is 0 if succeed, - 1 is returned for failure and error reason is stored in errno. +note: none +contact tel: 18720816902 +*/ int comm_proxy_bind(int sockfd, const struct sockaddr* ServerAddr, socklen_t addrlen) { SocketRequest req; @@ -439,6 +493,15 @@ int comm_proxy_bind(int sockfd, const struct sockaddr* ServerAddr, socklen_t add return result.s_ret; } +/* +function name: comm_proxy_listen +description: This function creates a socket interface and listens for the requested connection. +arguments: The first argument is a descriptor used to identify a bundled but unconnected socket. + The second argument indicates the maximum length of waiting for connection queue +return value: The return value is 0 if succeed, - 1 is returned for failure and error reason is stored in errno. +note: none +contact tel: 18720816902 +*/ int comm_proxy_listen(int sockfd, int backlog) { SocketRequest req;