[squeak-dev] IPv6-compatible addresses and sockets (was: Socket code from EToys)

Levente Uzonyi leves at elte.hu
Fri May 20 23:52:17 UTC 2011


On Thu, 19 May 2011, Bert Freudenberg wrote:

> On 19.05.2011, at 00:31, Levente Uzonyi wrote:
>
>> On Thu, 19 May 2011, Bert Freudenberg wrote:
>>
>>> What result do you get using the Etoys image? It uses the new SocketPlugin primitives (including IPv6 support), which if I see correctly have not been incorporated into Trunk yet.
>>
>> It's not in the Trunk yet. I extracted and converted the code, it's in the Inbox now, Network-ul.100.mcz. I didn't push it to the Trunk, because
>> 1) Cog doesn't support the new primitives and the fallback code has to be tested thoroughly.
>
> True. But maybe the new SocketPlugin would just work with Cog if somebody tried?

I think it would work, though I didn't try it.

>
>> 2) I don't really like SocketAddress, because IIRC it's like CompiledMethod, in the sense that it's a ByteArray, but it's storing
>> pointers/words.
>
> No, it does not store pointers. It's just a platform-dependent chunk of memory. See "man getnameinfo". POSIX requires to use that function to get fields out of the "sockaddr" struct.

Okay, I got it, but what will happen if I save an image with SocketAddress 
instances on Linux and open it on Windows? Will it crash if I try to use 
those SocketAddresses?

>
>> 3) SocketAddress lacks setter methods, so implementing compatibility methods, like ByteArray >> #asSocketAddress is a PITA.
>
> It's platform-dependent. You need to call the primitives to create proper SocketAddresses. That is encapsulated in the class SocketAddressInformation. See e.g. forHost:service:flags:addressFamily:socketType:protocol:.
>
> Btw, there is a method ByteArray>>#asSocketAddress. There are only two senders, it is only used when useOldNetwork is true. Not sure why this needs to be there. We could ask Michael what the idea was. I guess we could get rid of it.

Existing code (e.g.: all senders of Socket >> #connectTo:port:) uses 
ByteArrays where the new socket code expects SocketAddresses, so these 
conversion methods are mandatory.


Levente

>
> - Bert -
>
>
>
>



More information about the Squeak-dev mailing list