<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><BR><DIV><DIV>On Jun 4, 2006, at 9:37 AM, Florent Monnier wrote:</DIV><BR class="Apple-interchange-newline"><BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Hi,</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">First thanks for having explain me where to find the doc about the specs of<SPAN class="Apple-converted-space"> </SPAN></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">the X protocol. I've started to read it, and trying to understand it so to<SPAN class="Apple-converted-space"> </SPAN></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">begin I'm now trying to open the connection with the server.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Here is the piece of doc describing this part that I follow:</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><A href="http://www.linux-nantes.org/~fmonnier/OCaml/Xlib/init-X/protocol.html">http://www.linux-nantes.org/~fmonnier/OCaml/Xlib/init-X/protocol.html</A></DIV></BLOCKQUOTE><DIV><BR class="khtml-block-placeholder"></DIV>- first the byte order character (which looks ok), then a pad byte (missing)<BR><BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">- first I put the CARD16<SPAN class="Apple-converted-space"> </SPAN>11, then 6</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">- then I put two strings containing one char 0</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">=> then I'm trying to listen the answer, but the function which gets input<SPAN class="Apple-converted-space"> </SPAN></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">never returns.</DIV></BLOCKQUOTE><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Surely there are routines in ocaml to output integers or entire structures at once.</DIV><DIV>If not, you want to use output_byte instead, which does the (land 255) for you.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>For efficiency, you will eventually want to lay out entire Buffers of structures,</DIV><DIV>then write the whole buffer at once using output_buffer. (I hope. I'm not</DIV><DIV>sure what the restrictions are on the chars contained in a string/buffer.)</DIV><DIV><BR></DIV><DIV>You will eventually need access to actual 32-bit integers (the Int32 module).</DIV><DIV>It appears that the default ocaml int has less precision.</DIV><DIV><BR class="khtml-block-placeholder"></DIV>I guess the Marshal module is of no use, since it uses an Ocaml-specific format.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Maybe you could also look at the source for the GraphicsX11 and Pervasives</DIV><DIV>modules for inspiration.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">I have tryed to read at the code of the XopenDisplay from the Xlib, and its<SPAN class="Apple-converted-space"> </SPAN></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">equivalent in the XCB, but I quite don't understand everything since as you<SPAN class="Apple-converted-space"> </SPAN></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">know I'm not a C programmer.</DIV></BLOCKQUOTE><DIV><BR class="khtml-block-placeholder"></DIV>Knowledge of C will be required to complete your project, in my opinion.</DIV><DIV>Too much X behaviour is best described in source.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>You should model your code after the XCB internals, not the Xlib</DIV><DIV>internals, if you wish to retain your sanity. I presume you have already</DIV><DIV>obtained the xcb 0.9 package or pulled xcb from the GIT repository. Look in</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV> xcb/src/xcb_conn.c</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>for functions XCBConnectToFD(), write_setup() and read_setup().</DIV><DIV>Look in header</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV> xcb/src/xcb_types.h</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>for structure XCBSetupReq.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>ERROR: There is a pad byte that comes after the byte order char.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Look at the values for X_PROTOCOL* in</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV> xcb/src/xcb.h</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>ERROR: There you find them defined as 11 and 0, not 11 and 6.</DIV><DIV><BR><BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Well I don't know, maybe someone here could see the beginner error I'm making?</DIV></BLOCKQUOTE><DIV><BR class="khtml-block-placeholder"></DIV><DIV>ERROR: Well, you are only sending 3 bytes of a CARD32, but that doesn't affect this problem.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>If you still have problems, maybe set <FONT class="Apple-style-span" face="Courier" size="4"><SPAN class="Apple-style-span" style="font-size: 14px;">set_binary_mode_out out_channel true</SPAN></FONT>.</DIV><BR><BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">And you have told me that some of you were ML users in the past, so for those<SPAN class="Apple-converted-space"> </SPAN></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">here is my first attempt to open the connection:</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><A href="http://www.linux-nantes.org/~fmonnier/OCaml/Xlib/init-X">http://www.linux-nantes.org/~fmonnier/OCaml/Xlib/init-X</A></DIV></BLOCKQUOTE><DIV><BR class="khtml-block-placeholder"></DIV>Very pretty source formatting!</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Ian</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>(Note: I am not an ocaml expert, I just read the documentation at <A href="http://caml.inria.fr">http://caml.inria.fr</A>/ )</DIV><DIV><BR><BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Thanks in advance</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Florent</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">_______________________________________________</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Xcb mailing list</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><A href="mailto:Xcb@lists.freedesktop.org">Xcb@lists.freedesktop.org</A></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><A href="http://lists.freedesktop.org/mailman/listinfo/xcb">http://lists.freedesktop.org/mailman/listinfo/xcb</A></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV> </BLOCKQUOTE></DIV><BR></BODY></HTML>