Lines Matching refs:sockfd

33 bool StartConnect(int& sockfd, const char* path, const int timeout)
36 if ((sockfd = socket(AF_LOCAL, SOCK_STREAM, 0)) < 0) {
48 if (OHOS_TEMP_FAILURE_RETRY(setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, \
50 DFXLOGE("setsockopt(%{public}d) SO_RCVTIMEO error, errno(%{public}d).", sockfd, errno);
52 if (OHOS_TEMP_FAILURE_RETRY(setsockopt(sockfd, SOL_SOCKET, SO_SNDTIMEO, \
54 DFXLOGE("setsockopt(%{public}d) SO_SNDTIMEO error, errno(%{public}d).", sockfd, errno);
70 int connected = OHOS_TEMP_FAILURE_RETRY(connect(sockfd, reinterpret_cast<struct sockaddr *>(&server), len));
80 close(sockfd);
85 static bool GetServerSocket(int& sockfd, const char* name)
87 sockfd = OHOS_TEMP_FAILURE_RETRY(socket(AF_LOCAL, SOCK_STREAM, 0));
88 if (sockfd < 0) {
106 int ret = OHOS_TEMP_FAILURE_RETRY(setsockopt(sockfd, SOL_SOCKET, SO_PASSCRED, &optval, sizeof(optval)));
112 if (bind(sockfd, reinterpret_cast<struct sockaddr *>(&server),
121 bool StartListen(int& sockfd, const char* name, const int listenCnt)
126 sockfd = GetControlSocket(name);
127 if (sockfd < 0) {
129 if (GetServerSocket(sockfd, name) == false) {
135 if (listen(sockfd, listenCnt) < 0) {
137 close(sockfd);
138 sockfd = -1;
146 static bool RecvMsgFromSocket(int sockfd, unsigned char* data, size_t& len)
149 if ((sockfd < 0) || (data == nullptr)) {
168 if (OHOS_TEMP_FAILURE_RETRY(recvmsg(sockfd, &msgh, 0)) < 0) {
190 bool RecvMsgCredFromSocket(int sockfd, struct ucred* pucred)
193 if ((sockfd < 0) || (pucred == nullptr)) {
221 if (OHOS_TEMP_FAILURE_RETRY(recvmsg(sockfd, &msgh, 0)) < 0) {
242 bool SendMsgIovToSocket(int sockfd, void *iovBase, const int iovLen)
244 if ((sockfd < 0) || (iovBase == nullptr) || (iovLen == 0)) {
262 if (OHOS_TEMP_FAILURE_RETRY(sendmsg(sockfd, &msgh, 0)) < 0) {
269 static bool SendMsgCtlToSocket(int sockfd, const void *cmsg, const int cmsgLen)
271 if ((sockfd < 0) || (cmsg == nullptr) || (cmsgLen == 0)) {
300 if (OHOS_TEMP_FAILURE_RETRY(sendmsg(sockfd, &msgh, 0)) < 0) {
307 bool SendFileDescriptorToSocket(int sockfd, int fd)
309 return SendMsgCtlToSocket(sockfd, reinterpret_cast<void *>(&fd), sizeof(fd));
312 int ReadFileDescriptorFromSocket(int sockfd)
316 if (!RecvMsgFromSocket(sockfd, data, len)) {