<br><br><div class="gmail_quote">On Thu, May 14, 2009 at 8:57 PM, David Leimbach <span dir="ltr">&lt;<a href="mailto:leimy2k@gmail.com">leimy2k@gmail.com</a>&gt;</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">&lt;<a href="mailto:dons@galois.com" target="_blank">dons@galois.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div>&gt; I&#39;m speaking specifically of the encode/decode functions.  I have no idea how<br>
&gt; they&#39;re implemented.<br>
&gt;<br>
&gt; Are you saying that encode is doing something really simple and the default<br>
&gt; encodings for things just happen to be big endian?  If so, then I understand<br>
&gt; the pain.... but it still means I have to roll my own :-)  I guess if one must<br>
&gt; choose, big endian kind of makes sense, except that the whole world is little<br>
&gt; endian now, except for networks :-)  (No one *really* cares about anything but<br>
&gt; x86 anyway these days right?)<br>
<br>
</div>Oh, &#39;encode&#39; has type:<br>
<br>
    encode :: Binary a =&gt; a -&gt; 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&#39;t talking about Plan 9&#39;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&#39;s what I&#39;ve ended up trying to write to negotiate the &quot;version&quot; of a 9p server:</div><div><br></div><div><div>main = withSocketsDo $</div>
<div>       do </div><div>          ainfo &lt;- getAddrInfo Nothing (Just &quot;127.0.0.1&quot;) (Just &quot;6872&quot;)  -- hardcoded for now, it&#39;s an IRC filesystem server</div><div>          let a = head ainfo</div>
<div>          sock &lt;- 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 &quot;9P2000&quot;))</div></div><div> </div><div><br></div><div>I feel like I should use wireshark or something to watch the bytes :-)  I&#39;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>