Skip to content

Use separate bind and listen primitives instead of combined listenOn:… family #14593

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

Merged

Conversation

daniels220
Copy link
Contributor

@daniels220 daniels220 commented Sep 5, 2023

Fixes #11723

Separate primitives wrapping the bind() and listen() syscalls already exist, and have correct error/return-code handling, unlike the combined primSocket:listenOn:backlogSize: implementation. We can implement the combined version in terms of the separate ones and remove the combined primitive, significantly reducing plugin code.

Also supply default values (interface and backlog size) in the image, rather than rely on the primitive to accept varargs. This allows a user to better understand the behavior without access to VM source code. Supply reduced forms of the separate bind/listen messages as the home of these default values.

One question: Should there be an explicit socket state added for "bound but not listening or connected"? listen() will presumably fail on an unbound socket, so overall I'd prefer to reduce dependency on such extra state not increase it, but I thought I should mention it...

…... family

Separate primitives wrapping the bind() and listen() syscalls already exist, and have correct error/return-code handling, unlike the combined primSocket:listenOn:backlogSize: implementation. We can implement the combined version in terms of the separate ones and remove the combined primitive, significantly reducing plugin code.

Also supply default values (interface and backlog size) in the  image, rather than rely on the primitive to accept varargs. This allows a user to better understand the behavior without access to VM source code. Supply reduced forms of the separate bind/listen messages as the home of these default values.
@daniels220
Copy link
Contributor Author

daniels220 commented Sep 5, 2023

This is intended to go with removing the primSocket:listenOn:backlogSize:interface: primitive family from the VM/plugin, perhaps as part of pharo-vm#604, but it will work without any VM changes, just leaving those primitives unused.

Oh, and I realize I didn't make it clear in the commit message that the error-handling that exists in the separate primitives means this fixes #11723.

@svenvc
Copy link
Contributor

svenvc commented Sep 5, 2023

Nice!

@Ducasse
Copy link
Member

Ducasse commented Sep 6, 2023

Hi thanks for this contribution I flagged it for Pablo and he will have a look.

Copy link
Member

@guillep guillep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Thanks!

@jecisc
Copy link
Member

jecisc commented Sep 6, 2023

Since Guille reviewed it and tests passed I'm merging it

@jecisc jecisc merged commit b018c89 into pharo-project:Pharo12 Sep 6, 2023
@daniels220 daniels220 deleted the socket-separate-bind-and-listen branch November 2, 2023 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants