4
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
Noam M
  • 3,156
  • 5
  • 26
  • 41
  • Please check http://stackoverflow.com/questions/11631578/unix-domain-connect-no-such-file-or-directory – Denny Mathew May 17 '13 at 05:06
  • This page talks about connect() error-- I am getting problem while trying to send the data.. My connect is successful. Also send runs fine initialyy but after sometime. I start to face this error –  May 17 '13 at 05:10

1 Answers1

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.

glglgl
  • 89,107
  • 13
  • 149
  • 217
  • I am observing a strange behaviour. Output shows that sometimes i am getting i4RetVal = -1 and in some places i4RetVal is positive but still less than u2BufLen –  May 17 '13 at 09:48
  • As said, "i4RetVal is positive but still less than u2BufLen" is not strange - things just happen. – glglgl May 17 '13 at 10:10