Antwort: Re: Double-> String and String -> Double

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Antwort: Re: Double-> String and String -> Double

kobetic
"Dziedzic, Peter"<[hidden email]> wrote:
> i talked also with Mr Georg Heeg ( responsibly for Cincom support in
> Germany ).
>
> The best way would be a binary socket. But a binary socket needs to much
> implementation time.
> I am looking for a simple solution.
> One solution would be to send the two party of the double ( in german:
> exponent and mantisse ) seperate as integer over socket.

I don't see why binary socket would be any more difficult than non-binary (whatever we mean by that, since ultimately sockets are binary). Here's a sample that ships chunks of doubles over a socket connection:

        | doubles buffer received |
        doubles := (1 to: 10) reading collect: [ :i | i reciprocal asDouble ].
        buffer := UninterpretedBytes new: 8.
        received := OrderedCollection new.
        [ :client :server |
                [ doubles do: [ :double |
                                buffer doubleAt: 1 put: double.
                                client writeWait; writeFrom: buffer ].
                        client close.
                        [ (server readWait; bytesForRead) isZero
                        ] whileFalse: [
                                server readInto: buffer.
                                received add: (buffer doubleAt: 1) ].
                ] ensure: [ client close. server close ]
        ] valueWithArguments: SocketAccessor openPair.
        received

I can't resist to post an Xtreams based equivalent as well :-):

| doubles |
doubles := (1 to: 10) reading collect: [ :i | i reciprocal asDouble ].
[ :client :server |
        [ (client writing interpreting: #double) write: doubles; close.
                (server reading interpreting: #double) rest
        ] ensure: [ client close. server close ]
] valueWithArguments: SocketAccessor openPair.

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc