Hello,
I mounted an Ethernet shield 2 on a Due. As API I am using Ethernet library, version 2.0.
In a single write call, I send a buffer of 10K bytes to a remote client over LAN:
#include <Ethernet.h>
std::array<byte, 10000> bufferOut = {};
EthernetServer server(Port);
...
EthernetClient client = server.available();
...
if (client.available()) {
const std::uint32_t nbWritten = client.write(bufferOut.data(), bufferOut.size());
The number of bytes written returned is 10K. However on the receive side I only get 2048 bytes. The receiver is a simple QT client running on my PC:
#include <QTcpSocket>
socket = new QTcpSocket(this);
connect(socket, &QIODevice::readyRead, this, [this]() {
const std::uint64_t bytesAvailable = socket->bytesAvailable();
...
const std::uint64_t nbBytesRead = socket->read(bufferIn.data() + nbBytesReadTotal, bufferIn.size() - nbBytesReadTotal);
The QIODevice::readyRead callback is called one or two times to get a maximum of 2048 bytes in total, though 10K bytes were sent.
Could this be an issue with the 2048 bytes TX socket buffer of the Wiznet W5500 Ethernet chip? Increasing the socket buffer size by reducing the number of sockets in Ethernet.h makes it possible to send larger buffers.
Since TCP is stream orientated, it should be able to transmit any buffer sizes chunking them on its own, independently of the socket buffer size. Did I miss something?
Using a remote QT test server instead of the Arduino server, everything works as expected.
Any help appreciated.
Simon