alsaleem
alsaleem

Reputation: 387

socket send and EWOULDBLOCK

In socket communication:

  1. In blocking mode, send() will return the number of byte sent, then I have to repeat send() until all data has been sent or socket error.

  2. In non-blocking mode, send() will return with EAGAIN/EWOULDBLOCK error if it cannot send all data immediately, then, I will select() on writefds param until I have the signal.

My questions:

  1. Is the signal from select() for all data? (not partial).
  2. Is the error from select() as socket failure?

Upvotes: 0

Views: 1597

Answers (1)

user207421
user207421

Reputation: 310957

In non-blocking mode, send() will return with EAGAIN/EWOULDBLOCK error if it cannot send all data immediately

If it cannot send any data immediately.

  1. Is the signal from select() for all data? (not partial).

All what data? What does select() know about your data? All that it is telling you is that the socket has now become writable, which means there is some space in the kernel socket send buffer, which means that a send() will now transfer at least one byte.

  1. Is the error from select() as socket failure?

If select() returns -1, there is either an error in the parameters or an invalid FD supplied to one of the select sets: typically, one that has been closed.

Upvotes: 1

Related Questions