<br><br><div class="gmail_quote">On Thu, May 14, 2009 at 8:57 PM, David Leimbach <span dir="ltr"><<a href="mailto:leimy2k@gmail.com">leimy2k@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br><br><div class="gmail_quote"><div><div></div><div class="h5">On Thu, May 14, 2009 at 8:54 PM, Don Stewart <span dir="ltr"><<a href="mailto:dons@galois.com" target="_blank">dons@galois.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>> I'm speaking specifically of the encode/decode functions. I have no idea how<br>
> they're implemented.<br>
><br>
> Are you saying that encode is doing something really simple and the default<br>
> encodings for things just happen to be big endian? If so, then I understand<br>
> the pain.... but it still means I have to roll my own :-) I guess if one must<br>
> choose, big endian kind of makes sense, except that the whole world is little<br>
> endian now, except for networks :-) (No one *really* cares about anything but<br>
> x86 anyway these days right?)<br>
<br>
</div>Oh, 'encode' has type:<br>
<br>
encode :: Binary a => a -> ByteString<br>
<br>
it just encodes with the default instances, which are all network order:<br>
<br>
<a href="http://en.wikipedia.org/wiki/Endianness#Endianness_in_networking" target="_blank">http://en.wikipedia.org/wiki/Endianness#Endianness_in_networking</a><br></blockquote><div><br></div></div></div><div>Yeah I understand that Big Endian == Network Byte Order... which would be true, if I wasn't talking about Plan 9's 9P protocol which specifies little endian bytes on the wire (as far as I can tell anyway from the man page).</div>
<div><br></div><div>Dave</div></div></blockquote><div><br></div><div>FYI here's what I've ended up trying to write to negotiate the "version" of a 9p server:</div><div><br></div><div><div>main = withSocketsDo $</div>
<div> do </div><div> ainfo <- getAddrInfo Nothing (Just "127.0.0.1") (Just "6872") -- hardcoded for now, it's an IRC filesystem server</div><div> let a = head ainfo</div>
<div> sock <- socket AF_INET Stream defaultProtocol</div><div> connect sock (addrAddress a)</div><div> sendAll sock $ (toLazyByteString (putWord32le (fromIntegral (16 ::Int32))))</div><div> sendAll sock $ (encode (100 ::Int8))</div>
<div> sendAll sock $ (toLazyByteString (putWord32le (fromIntegral (1024 ::Int32))))</div><div> sendAll sock $ (encode (C.pack "9P2000"))</div></div><div> </div><div><br></div><div>I feel like I should use wireshark or something to watch the bytes :-) I'm not feeling very sure about this.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="gmail_quote"><div></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<font color="#888888"><br>
-- Don<br>
</font></blockquote></div><br>
</blockquote></div><br>