Thanks for the reply.<div><br></div><div>The following is what pushed me into researching the problem - I've created a test application that sets up a display and tries to create a client that connects to that display, but the client does not connect.</div>
<div><br></div><div>Just as in compositor, I create a wl_display, add a socket to it and run the wayland event loop (through wl_display_run). I add a timer that sets off in ~2 seconds and sets up the client.</div><div><br>
</div><div>Setting up the client starts as usual, calling wl_display_connect to connect to the display via socket. Then a listener for events is set up and the client enters the iteration to get all the events.</div><div>
<br></div><div>The problem is that apparently when server and client are both living in the same program, socket_data doesn't get called because the client enters the iteration 'too soon' and then enters an infinite loop in wl_connection_data where client is waiting for data but it never receives any. Because socket_data doesn't get called, a client does not get created on server side and no events are passed onto it.</div>
<div><br></div><div>But if I add another timer that puts off the iteration for one second, socket_data does get called and a client is created and is capable of receiving data.</div><div><br></div><div>Any ideas?</div><div>
<br></div><div>Regards,</div><div>Zan Dobersek</div><div><br></div><div><div class="gmail_quote">On Tue, Jan 18, 2011 at 10:51 PM, Marty Jack <span dir="ltr"><<a href="mailto:martyj19@comcast.net">martyj19@comcast.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">You have it right.<br>
<br>
When a client does a connect on a socket that another process is listening to (the listen is at line 692), this makes the other end get a "readable" on its end of the socket. You then do an accept, which gives you a new fd for your end of the connection. You then have a bidirectional path between the client's end and the compositor's end. If you write data down one end, it is readable at the other, and vice versa.<br>
<br>
In this case it is what is called a "UNIX domain socket", which is represented by an entry in the file system.<br>
<br>
man 2 listen, man 2 accept, man 7 unix, any tutorial on networking<br>
<div><div></div><div class="h5"><br>
On 01/18/2011 04:15 PM, Zan Dobersek wrote:<br>
> Greetings,<br>
><br>
> I'm wondering what exactly sets off the socket_data function in wayland/wayland-server.c at approximate line 640. I can see that we add a file descriptor object of our socket to the main loop in wl_display_add_socket that uses socket_data as the callback function when a client connects to that socket. Subsequently, we accept the connection in socket_data and create a new client.<br>
><br>
> So, what is it in client's code that causes socket_data to be called? Is it just the mere connect() call to establish a connection through that socket or is it anything more complex that I have missed?<br>
><br>
> My knowledge of sockets is quite basic, so I would be happy if someone would clarify how exactly this bit of code is executed.<br>
><br>
> Regards,<br>
><br>
> Zan Dobersek<br>
><br>
><br>
><br>
</div></div>> _______________________________________________<br>
> wayland-devel mailing list<br>
> <a href="mailto:wayland-devel@lists.freedesktop.org">wayland-devel@lists.freedesktop.org</a><br>
> <a href="http://lists.freedesktop.org/mailman/listinfo/wayland-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/wayland-devel</a><br>
_______________________________________________<br>
wayland-devel mailing list<br>
<a href="mailto:wayland-devel@lists.freedesktop.org">wayland-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/wayland-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/wayland-devel</a><br>
</blockquote></div><br></div>