-
-
Notifications
You must be signed in to change notification settings - Fork 361
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
Socket>>#listenOn:backlogSize:
doesn’t signal an error if another socket is already listening on the same port
#11723
Comments
I’m not sure I’m looking at the right function in ‘SocketPlugin’, but I see that in ‘sqSocketListenOnPortBacklogSizeInterface’ the return values of the ‘bind’ and ‘listen’ calls on lines 865 and 869 are not used. |
Yes this is an old issue (i.e. it has existed for a long time): when binding/listening no error is signalled when the socket is already in use. This is of course a PITA (see the Zinc issue that you created). I am sure the plugin code could be much improved and simplified. The challenge remains the cross platform portability though. A developer who could do Linux/macOS is probably ill suited to handle Windows and vice versa. The same is true for plain and secure networks streams, BTW. Much could be improved/simplified. |
This seems to be not consistent across the primitives; quoting issue #11544:
In ‘sqSocketBindToPort’, the return value of the ‘bind’ call does get checked. So in the following example, the second send of socket3 := Socket newTCP.
socket3 bindTo: NetNameResolver localHostAddress port: 1702.
socket4 := Socket newTCP.
socket4 bindTo: NetNameResolver localHostAddress port: 1702. And |
11544 has been fixed by merging #11921 |
The plugin code could definitely be massively simplified. AFAICT, the entire
Does this seem like a good next step, even if there's plenty more to do? If so, I can make a PR for the image side of things, which doesn't require any VM changes to work, just opens the door for cleaning up cruft. In turn, I'm less than entirely confident I can get all the cruft on the C side—I can try, but is someone willing to help with that? |
In the “pharo-vm” repository, there’s an open pull request titled “Feat/improvements in sockets”, I’d suggest to ask there how what you’re proposing could fit in with what they’re working on. Commit 01b21b8963ebcf7c would at least already seem to foil the evil person’s scheme to twist the very nature of reality. |
I submitted a PR implementing the suggestion to use only the separate bind/listen primitives, which should fix this issue if/once accepted. |
Hi all, @daniels220, I believe PR #14593 is good and it should come through in the next couple of hours ;) @Rinzwind, I talked with Pablo, his PR pharo-project/pharo-vm#604 is a work in progress, so do not hesitate to do another smaller PR, we will take care of the merge. About the original issue, I acknowledge it is a PITA too, @daniels220 can you confirm that #14593 fixes this issue? |
Nevermind, I just saw the comment in the PR :) |
In the following example, no error is signaled; shouldn’t the second send of
#listenOn:backlogSize:
signal an error as the first socket is already listening on the same port?Version information:
Pharo-11.0.0+build.224.sha.6fcd6c1aaf965912b63ffc2ef2059d10cf57c744 (64 Bit)
Pharo 9.0.18 built on Sep 2 2022 16:54:02 Compiler: 4.2.1 Compatible Apple LLVM 11.0.3 (clang-1103.0.32.29)
The text was updated successfully, but these errors were encountered: