Mercurial > repos > rhope
comparison net.rhope @ 164:429afd920a23
Allow sending and receiving arrays of arbitrary objects rather than just UInt8s
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 10 Jan 2011 00:25:35 -0500 |
parents | e9a8269384bb |
children | 1bfc19076f1b |
comparison
equal
deleted
inserted
replaced
163:9fab36cc706b | 164:429afd920a23 |
---|---|
294 | 294 |
295 Write@TCP Connection[con,buffer(Array):out,err] | 295 Write@TCP Connection[con,buffer(Array):out,err] |
296 { | 296 { |
297 If[[buffer]Length] | 297 If[[buffer]Length] |
298 { | 298 { |
299 out,err <- [con]_Write[buffer,0] | 299 If[[Raw Size[[buffer]Eltype >>]] > [1]] |
300 { | |
301 bytelen <- [[buffer]Length]*[Raw Size[[buffer]Eltype >>]] | |
302 //Copy to a byte buffer until we have a better way of writing from an arbitrary byte offset | |
303 bbuffer <- [_internal_array_copychunk[buffer, 0, _internal_array_allocnaked[bytelen, UInt8()], 0, [buffer]Length]]Length <<[bytelen] | |
304 }{ | |
305 bbuffer <- Val[buffer] | |
306 } | |
307 out,err <- [con]_Write[bbuffer,0] | |
300 }{ | 308 }{ |
301 out <- con | 309 out <- con |
302 } | 310 } |
303 } | 311 } |
304 | 312 |
377 buflist <- () | 385 buflist <- () |
378 } | 386 } |
379 ,out con,err <- [[con]Read Buffer <<[Array[]]]_Read[ntoread,buflist] | 387 ,out con,err <- [[con]Read Buffer <<[Array[]]]_Read[ntoread,buflist] |
380 { data <- _Merge Buffers[~] } | 388 { data <- _Merge Buffers[~] } |
381 } | 389 } |
390 } | |
391 } | |
392 | |
393 Read Type@TCP Connection[con,toread(Int32),type(Blueprint):data,out con,err] | |
394 { | |
395 toreadbytes <- [toread]*[Raw Size[type]] | |
396 ,out con,err <- [con]Read[toreadbytes] | |
397 { | |
398 data <- [_internal_array_copychunk[~, 0, _internal_array_allocnaked[toread, type], 0, toreadbytes]]Length <<[toread] | |
382 } | 399 } |
383 } | 400 } |
384 | 401 |
385 _Check Partial[buffer,delim,offset:partial,none] | 402 _Check Partial[buffer,delim,offset:partial,none] |
386 { | 403 { |