質問

if (fcntl (i4SockDesc, F_SETFL, O_NONBLOCK) < 0)
{
    printf(LDP_IF_MISC, "LDPTCP: Client : Can't Set Sckt in NON BLK\n");
    return CONNECT_FAIL;
}

i4RetVal = send (i4SockDesc, (UINT1 *) pu1Data, u2BufLen, MSG_NOSIGNAL);
if (i4RetVal != u2BufLen)
{
    perror("Socket send failure!!\n");
    printf(i4SockDesc = %d, u2BufLen = %d, i4RetVal = %d\n", i4SockDesc, u2BufLen, i4RetVal);
    printf("Socket send Failure: %s, errno = %d\n",strerror(errno), errno);
}

The send() call is getting failed with the perror " No such file or Directory" errno = 2.

i4SockDesc = 90, u2BufLen = 100, i4RetVal = -1
Socket send Failure: No such file or directory, errno = 2
役に立ちましたか?

解決

It is not a failure yet if send() actually sends less bytes han requested. I suppose your errno happend earlier.

If i4RetVal < u2BufLen you should just continue sending after advancing your "send cursor" by i4RetVal and reducing the buf length (better: the length to be sent) by the same amount.

Continue doing so until you really have sent everything.

You only should check for errors if i4RetVal < 0.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top