mirror of https://github.com/ARMmbed/mbed-os.git
67b97d39c4
Previously, send() was somewhat soft - it only ever made one send call to the underlying stack, so it would typically take as much data as would fit in the buffer, and only block if it was unable to write anything. This is not the intent of a POSIX socket/filehandle write. It should try to send everything if blocking, and only send less if interrupted by a signal: - If the O_NONBLOCK flag is clear, write() shall block the calling thread until the data can be accepted. - If the O_NONBLOCK flag is set, write() shall not block the thread. If some data can be written without blocking the thread, write() shall write what it can and return the number of bytes written. Otherwise, it shall return -1 and set errno to [EAGAIN]. This "send all" behaviour is of slightly limited usefulness in POSIX, as you still usually have to worry about the interruption possibility: - If write() is interrupted by a signal before it writes any data, it shall return -1 with errno set to [EINTR]. - If write() is interrupted by a signal after it successfully writes some data, it shall return the number of bytes written. But as mbed OS does not have the possibility of signal interruption, if we strengthen send to write everything, we can make applications' lives easier - they can just do "send(large amount)" confident that it will all go in one call (if no errors). So, rework to make multiple sends to the underlying stack, blocking as necessary, until all data is written. This change does not apply to recv(), which is correct in only blocking until some data is available: - If O_NONBLOCK is set, read() shall return -1 and set errno to [EAGAIN]. - If O_NONBLOCK is clear, read() shall block the calling thread until some data becomes available. - The use of the O_NONBLOCK flag has no effect if there is some data available. |
||
---|---|---|
.. | ||
cellular | ||
CellularBase.h | ||
CellularInterface.h | ||
EthInterface.h | ||
MeshInterface.h | ||
NetworkInterface.cpp | ||
NetworkInterface.h | ||
NetworkStack.cpp | ||
NetworkStack.h | ||
Socket.cpp | ||
Socket.h | ||
SocketAddress.cpp | ||
SocketAddress.h | ||
TCPServer.cpp | ||
TCPServer.h | ||
TCPSocket.cpp | ||
TCPSocket.h | ||
UDPSocket.cpp | ||
UDPSocket.h | ||
WiFiAccessPoint.cpp | ||
WiFiAccessPoint.h | ||
WiFiInterface.h | ||
emac_stack_mem.h | ||
mbed_lib.json | ||
nsapi.h | ||
nsapi_dns.cpp | ||
nsapi_dns.h | ||
nsapi_ppp.h | ||
nsapi_types.h |