From: Aigner R. <rol...@fh...> - 2020-08-04 11:36:10
|
Hi everyone, I'm using the lowlevel API with UDP for unidirectional OSC for some time now and for my current use case I'm trying now to switch to TCP. However, I'm having trouble understanding how to use the library. The example_tcp_echo_server demonstrates how to set up a server and I tried to replicate this. Basically, the way I got it, I have to do this: //setup server to listen at localhost:7000 _tcpThread = lo_server_thread_new_with_proto( "7000", LO_TCP, errorHandler ); _tcpServer = lo_server_thread_get_server( _tcpThread ); lo_server_thread_start( _tcpThread ); //send to client at localhost:7001 _address = lo_address_new_with_proto( LO_TCP, "127.0.0.1", "7001" ); lo_send_message_from( _address, _tcpServer, "/test", message ); 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. 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. But how do I know when a client connection gets accepted? So, summarizing, my two remaining questions are 1. how do I connect a client to the server? 2. how do I know what clients are currently connected that I would have to send my packages to? Thanks, Roland |