[squeak-dev] IPv6-compatible addresses and sockets (was: Socket
code from EToys)
Bert Freudenberg
bert at freudenbergs.de
Mon May 23 08:38:01 UTC 2011
On 21.05.2011, at 01:52, Levente Uzonyi wrote:
> 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?
I don't know. SocketAddress instances are supposed to be temporary, IIUC, application code would not store them.
>>> 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.
#connectTo:port: has been changed to use either the old or the new socket code.
Anyhow: are you suggesting the extended SocketPlugin is completely useless, or that we should not use Michael's new in-image code?
IMHO the new primitives are a good foundation for the networking code to move forward. If we don't like how it's been integrated in the image, I would rather change (or even completely rewrite) that image code, encapsulating the new primitives as needed. But the plugin itself seems solid to me.
- Bert -
More information about the Squeak-dev
mailing list
|