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

Add SocketAddressInformation for IPv6 support #16879

Merged
merged 3 commits into from
Aug 30, 2024

Conversation

Rinzwind
Copy link
Contributor

@Rinzwind Rinzwind commented Jul 7, 2024

This pull request adds SocketAddressInformation and some auxiliary methods on Socket, copied from Squeak 6.1 alpha 22998, to allow making use of SocketPlugin’s IPv6 support. The methods #primSocket:bindTo: and #primSocket:connectTo: in Socket’s protocol ‘primitives - ipv6’ previously had no senders.

With SocketAddressInformation, a listening socket using IPv6 can be set up as follows:

addressInformations := SocketAddressInformation forHost: ''
	service: 2000 asString
	flags: SocketAddressInformation passiveFlag
	addressFamily: SocketAddressInformation addressFamilyINET6
	socketType: SocketAddressInformation socketTypeStream
	protocol: SocketAddressInformation protocolTCP.
listeningSocket := addressInformations first listenWithBacklog: 5.
[
	acceptedSocket := listeningSocket waitForAcceptFor: 300.
	Transcript show: 'Received data: ' , acceptedSocket receiveData; cr.
	acceptedSocket close.
	listeningSocket close.
] fork.

It can then be connected to as follows:

addressInformations := SocketAddressInformation forHost: ''
	service: 2000 asString
	flags: 0
	addressFamily: SocketAddressInformation addressFamilyINET6
	socketType: SocketAddressInformation socketTypeStream
	protocol: SocketAddressInformation protocolTCP.
connectedSocket := addressInformations first connect.
connectedSocket sendData: DateAndTime now asString; close.

A motivation for this pull request is the problem I encountered with Safari in Pharo VM pull request #816 when using IPv4.

Rinzwind added 3 commits July 7, 2024 22:52
…NetNameResolver (copied from Squeak 6.1 alpha 22998 without the methods #listenWithBacklog: and #connect).
…d #bindTo:, #connectNonBlockingTo:, #connectTo:, #connectTo:waitForConnectionFor: and #waitForConnectionFor:ifTimedOut:ifRefused: on Socket (copied from Squeak 6.1 alpha 22998 with the send of #waitTimeoutMSecs: in the last method changed to send #waitTimeoutMilliseconds: instead).
@Ducasse
Copy link
Member

Ducasse commented Jul 21, 2024

@tesonep I propose to merge it.

@MarcusDenker MarcusDenker reopened this Jul 25, 2024
@guillep guillep merged commit 34e6853 into pharo-project:Pharo13 Aug 30, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants