if ((unsigned)(socket - 1) > (SOCKET_POOL_SIZE - 1)) {
return -1;
}
I noticed that if the socket number is 0, then socket_close() will always fail. Is socket 0 a special socket that can’t be closed? The problem I’m having is that a call to socket() sometimes returns 0, and I’m unable to close that socket due to this issue.
Hi Sam,
can you try with PR #6004 which ports POSIX sockets from conn to sock? There are still some kinks in this PR, but I plan to fix them until the release. On another note: the conn implementation of sockets was never tested with TCP (since there was no TCP implementation then), but feel free to test (and hopefully fix) any issues in that PR.
I will work on testing it with sock and PR #6004, but it may take some time since I might need to port the interface from conn to sock.
It seems to me that conn is deprecated and that sock is its replacement moving forward. Am I correct? And what is the motivation for moving away from conn?
but perhaps there is some reasoning behind the original check that I am not aware of. Could someone more familiar with the sock code please take a look?
Hi Sam,
you are right. `assert(((unsigned)socket) <
(_ACTUAL_SOCKET_POOL_SIZE));` should be the right one... with `0 <=
socket` as you gave it only 0 and negative socket ids would be allowed
which is definetly allowed ;-). I provided a PR to fix that [1]. If
you spot any more errors don't be afraid to provide your own PR to fix
them.