mbed-os/features/netsocket
Kevin Bracey 67b97d39c4 Make TCPSocket send all data when blocking
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.
2017-11-21 09:51:36 +02:00
..
cellular Merge pull request #5016 from u-blox/apndb_fix 2017-09-27 09:06:46 -05:00
CellularBase.h Major Refactoring & extensions 2017-05-31 15:02:11 +03:00
CellularInterface.h Remove doxygen warnings in nsapi 2017-06-05 17:32:46 -05:00
EthInterface.h Add tags to our code 2016-10-04 15:02:44 -05:00
MeshInterface.h Add tags to our code 2016-10-04 15:02:44 -05:00
NetworkInterface.cpp nsapi - Added standardized return types for size and errors 2016-11-02 15:25:22 -05:00
NetworkInterface.h Remove doxygen warnings in nsapi 2017-06-05 17:32:46 -05:00
NetworkStack.cpp nsapi - Fixed missing NSAPI_UNSPEC check in gethostbyname for ip literals 2016-11-08 18:05:35 -06:00
NetworkStack.h Remove doxygen warnings in nsapi 2017-06-05 17:32:46 -05:00
Socket.cpp Add multicast implementation for UDPSocket. IPv4 and IPv6 both supported. 2017-10-10 18:21:18 -05:00
Socket.h Add multicast implementation for UDPSocket. IPv4 and IPv6 both supported. 2017-10-10 18:21:18 -05:00
SocketAddress.cpp netsocket - Fix set_ip_bytes out-of-bound access 2016-11-04 11:02:34 +08:00
SocketAddress.h Remove doxygen warnings in nsapi 2017-06-05 17:32:46 -05:00
TCPServer.cpp nsapi: Changed initial state of sockets to allow events 2017-01-20 07:58:34 -06:00
TCPServer.h Remove doxygen warnings in nsapi 2017-06-05 17:32:46 -05:00
TCPSocket.cpp Make TCPSocket send all data when blocking 2017-11-21 09:51:36 +02:00
TCPSocket.h Make TCPSocket send all data when blocking 2017-11-21 09:51:36 +02:00
UDPSocket.cpp Add multicast implementation for UDPSocket. IPv4 and IPv6 both supported. 2017-10-10 18:21:18 -05:00
UDPSocket.h RTOS: Add EventFlags class 2017-08-29 14:07:44 -05:00
WiFiAccessPoint.cpp Merge remote-tracking branch 'upstream/master' into feature_wifi_ublox_merge 2016-10-02 07:29:07 -05:00
WiFiAccessPoint.h Fixed missing public 2016-10-04 15:52:56 +02:00
WiFiInterface.h Remove doxygen warnings in nsapi 2017-06-05 17:32:46 -05:00
emac_stack_mem.h Turn on doxygen for DEVICE_* features 2017-08-11 15:47:44 -05:00
mbed_lib.json restructure - Restructured features/net directory 2016-09-30 19:18:09 -05:00
nsapi.h Add tags to our code 2016-10-04 15:02:44 -05:00
nsapi_dns.cpp NSAPI - Don't send trailing garbage in DNS queries 2017-05-05 11:35:48 +03:00
nsapi_dns.h nsapi - Added standardized return types for size and errors 2016-11-02 15:25:22 -05:00
nsapi_ppp.h Either ipv4 or ipv4v6 PPP and IP stacks are enabled based on 3GPP context 2017-08-22 13:14:41 +03:00
nsapi_types.h Add multicast implementation for UDPSocket. IPv4 and IPv6 both supported. 2017-10-10 18:21:18 -05:00