From: Stephen S. <rad...@gm...> - 2020-08-06 15:44:19
|
Ah right, you do make a good point ;) I believe the terminology choice in this case stems from "device accepting connections" (like an HTTP server), as opposed to "device requesting connections" (like an HTTP client). I can try to clarify that in the docs, thanks. regards, Steve On Wed, Aug 5, 2020 at 5:59 PM Aigner Roland <rol...@fh...> wrote: > Hi Steve, > > > > Thanks for your detailed reply, that did indeed help. The cause for > confusion is in fact terminology and what I would associate with the term > “server” (i.e. a device providing data) and that the notation is apparently > different here (a device consuming data). > > > > Also thanks a ton for providing liblo as free software, it’s real helpful! > > > > Best, > > Roland > > > > > > > > *From:* Stephen Sinclair <rad...@gm...> > *Sent:* Tuesday, August 4, 2020 6:16 PM > *To:* liblo development list <lib...@li...> > *Subject:* Re: [liblo] how to connect to a liblo TCP OSC server? > > > > Hi Roland, > > > > > > On Tue, Aug 4, 2020 at 1:36 PM Aigner Roland < > rol...@fh...> wrote: > > However I struggle to figure out how I would connect a client to this > server, i.e. what the code should look like for a client receiving the data > sent by this server. > > > > I'm not sure if your concept of client and server is mixed up here? In > OSC it is the client sending data to the server. > > > > Documentation and sample code leave me scratching my head, I tried to > figure out by checking the library source code, but so far I failed to > understand. From the fact that lo_send_message_from requires a target > address I infer that I would have to iterate through all connected clients > and sent to the respective sockets manually. > > > > You can get a target address by creating one, if you know the destination, > or you can get the sender's address from inside a message handler: > > > > lo_address a = lo_message_get_source(data); > > lo_send(a, "/hi", "i", 3); > > > > But how do I know when a client connection gets accepted? > > > > Who knows? The server knows because a handler is being executed. The > client only knows whether the send failed. > > > > > > So, summarizing, my two remaining questions are > > 1. how do I connect a client to the server? > > > > Your code (which I snipped from the message, apologies) is correct. You > just create a server and specify LO_TCP for its protocol, and a client > specifying LO_TCP for its protocol. Then the client should be able to make > a connection to the server and send it a message. > > > > > > > > 1. how do I know what clients are currently connected that I would > have to send my packages to? > > > > Hm, I don't think liblo provides a way to enumerate the current client > connections.. could be interesting, but it's not too usual to want to > broadcast to a random client. Usually messages from the server are limited > to _responses_ that are sent during message handlers, and in that case you > can get the response destination using lo_message_get_source as I outlined > above. > > > > Note that if your *client* wants to receive a response... actually it > cannot, it needs to set up a *server* to receive the response, and use > lo_send_from, specifying that server. That's how the destination server > can find where to send responses back to. So for bidirectional messaging, > each side has a server. > > > > If you need to broadcast a message to multiple servers, you can look into > multicast or broadcast messaging, but that's for UDP. > > > > As for sending a message to all currently connected clients, I'm not > sure.. I'll have to think on how to do that and whether it's a good idea. > Theoretically it is possible. > > > > Keep in mind that OSC is typically a UDP protocol and is designed around > one-way messaging. Liblo incidentally supports responses, but it's common > for UDP protocols to be unidirectional. > > On the TCP side, often clients will make a connection, send a message, > *maybe* wait for a response, and then close the connection. Long-lived > connections are more rarely used; but if they are, they shouldn't *depend* > on the connection state. > > > > Hope this helps, > > Steve > > > _______________________________________________ > liblo-devel mailing list > lib...@li... > https://lists.sourceforge.net/lists/listinfo/liblo-devel > |