socket循环接收
This commit is contained in:
@@ -161,7 +161,7 @@ int readNlSock(int sockFd, char *bufPtr, int seqNum, int pId)
|
|||||||
{
|
{
|
||||||
struct nlmsghdr *nlHdr = NULL;
|
struct nlmsghdr *nlHdr = NULL;
|
||||||
int readLen = 0, msgLen = 0;
|
int readLen = 0, msgLen = 0;
|
||||||
do{
|
while(1){
|
||||||
//收到内核的应答
|
//收到内核的应答
|
||||||
if((readLen = recv(sockFd, bufPtr, BUFSIZE - msgLen, 0)) < 0)
|
if((readLen = recv(sockFd, bufPtr, BUFSIZE - msgLen, 0)) < 0)
|
||||||
{
|
{
|
||||||
@@ -192,12 +192,11 @@ int readNlSock(int sockFd, char *bufPtr, int seqNum, int pId)
|
|||||||
bufPtr += readLen;
|
bufPtr += readLen;
|
||||||
msgLen += readLen;
|
msgLen += readLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((nlHdr->nlmsg_flags & NLM_F_MULTI) == 0)
|
if((nlHdr->nlmsg_flags & NLM_F_MULTI) == 0)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} while((nlHdr->nlmsg_seq != seqNum) || (nlHdr->nlmsg_pid != pId));
|
}
|
||||||
|
|
||||||
return msgLen;
|
return msgLen;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user