# HG changeset patch # User Mike Pavone # Date 1294637135 18000 # Node ID 429afd920a23dd29c50cb42bd268a6e82b537fa7 # Parent 9fab36cc706b8006bd13211754502628532a3090 Allow sending and receiving arrays of arbitrary objects rather than just UInt8s diff -r 9fab36cc706b -r 429afd920a23 net.rhope --- a/net.rhope Sun Jan 09 23:03:30 2011 -0500 +++ b/net.rhope Mon Jan 10 00:25:35 2011 -0500 @@ -296,7 +296,15 @@ { If[[buffer]Length] { - out,err <- [con]_Write[buffer,0] + If[[Raw Size[[buffer]Eltype >>]] > [1]] + { + bytelen <- [[buffer]Length]*[Raw Size[[buffer]Eltype >>]] + //Copy to a byte buffer until we have a better way of writing from an arbitrary byte offset + bbuffer <- [_internal_array_copychunk[buffer, 0, _internal_array_allocnaked[bytelen, UInt8()], 0, [buffer]Length]]Length <<[bytelen] + }{ + bbuffer <- Val[buffer] + } + out,err <- [con]_Write[bbuffer,0] }{ out <- con } @@ -382,6 +390,15 @@ } } +Read Type@TCP Connection[con,toread(Int32),type(Blueprint):data,out con,err] +{ + toreadbytes <- [toread]*[Raw Size[type]] + ,out con,err <- [con]Read[toreadbytes] + { + data <- [_internal_array_copychunk[~, 0, _internal_array_allocnaked[toread, type], 0, toreadbytes]]Length <<[toread] + } +} + _Check Partial[buffer,delim,offset:partial,none] { none <- If[[offset]=[[buffer]Length]] {}