Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SetSocketSize seems to be circumvented #28

Open
clevertoys opened this issue Feb 21, 2022 · 0 comments
Open

SetSocketSize seems to be circumvented #28

clevertoys opened this issue Feb 21, 2022 · 0 comments

Comments

@clevertoys
Copy link

clevertoys commented Feb 21, 2022

Code such as this silently fails to change the recv buf size, and incoming packets never arrive

// start UDP
Ethernet.setSocketSize(1620 * 3);
Udp.begin(T_PORT);

I looked at the code and found this:

void EthernetClass::setSocketSize(size_t _socket_size)
{
if(socket_size != 0) return;
socket_size = _socket_size;
}

This effectively disallows setting of the size unless the size is zero. No idea who sets the initial value, but it isn't zero when I call setSocketSize, and so my call has no effect. I doubt that is what was intended, but please let me know if I am missing something here. I changed the code to this:

void EthernetClass::setSocketSize(size_t _socket_size)
{
//if(socket_size != 0) return;
socket_size = _socket_size;
}

And now all is working fine for me. I think what you want here is something like (NOTE: I do not know where the actual max packet size is to be found. I just used a made up symbol MAX_MTU here...)

void EthernetClass::setSocketSize(size_t _socket_size)
{
if(_socket_size > MAX_MTU) _socket_size = MAX_MTU;
socket_size = _socket_size;
}

I found this:

#define UDP_TX_PACKET_MAX_SIZE 2048

but it is never used. In any case, I think programs should be allowed to set the recv buf size up to the actual limit of the physical transport, whatever that might be...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant