[Stk] how does incoming TCP/IP data trigger your socket?

Andreas Krüger services@andreaskrueger.de
Fri, 23 Jan 2004 18:38:56 +0100


Hi!

I am using your STK-library. Thanks for it, 
it's really impressive and works well,
and first of all, I found it googling for 
"platform independent MIDI C++ library",
with a strong emphasis on "platform independent".

Analyzing your demo and cutting it down to a client-server skeleton, 
I have a question now. I am not a TCP/IP specialist, not in Windows/
Winsock anyway - I used Qt (trolltech.com) for such purposes up to now.

  Do your communication classes Messager and Socket DEMAND a server-side 
  global runtime LOOP in main() to receive from a client over a socket
  by  "type = messager->nextMessage();" ?

Or to put it the other way around: 
  Does the operating system socket routine send some signal whenever 
  there is incoming data - and DOES your library catch that signal? 
  WHERE is that implemented in your library?

Or a third formulation of the same idea:
  Where could I put "_one_line_of_code_" to inform MY program 
  of incoming TCP/IP - SKINI data so that it starts a 
  "messager->nextMessage()" until the buffer is empty again?


The background is that I would like to use a MIDI-device to control
my own program. I very much like your construction
 MIDI -> SKINI -> CLIENT 
                           --|--> 
                                    SERVER -> SKINI -> action
because TCP-IP even enables me to delocalize between input and output,
something I didn't think of before, but which seems very handy...
N.B.: REALTIME/latency-free processing is not priority #1 for me
at the moment.

The punchline is that I do not want to spend all server-CPU time 
in a global STK-receive loop, but rather want to react to incoming data
only when there is incoming data. And then quickly of course.

(At least after one connection is established,) the server should 
(leave the global runtime loop and) only react to incoming data
by some trigger.

If you can't answer my question, I will probably just check for 
"messager->nextMessage();" every 100 milliseconds, but that isn't
as elegant as I'd prefer it to be. 
Qt has an advanced SIGNAL-SLOT conception where any function can be 
bound to a SLOT and that SLOT bound to a specific SIGNAL, that is 
EMITTED whenever appropriate.

 Where exactly in your library is a good routine to put my one line
 of code that EMITS such a SIGNAL for incoming SKINI-data?

Thanks a lot!
Again: I very much appreciate your work. 
It is exactly what I was looking for!

Greetings from a cold but at least not rainy Germany
;-)
   Andreas


P.S.: Is there some documentation about the server client protocoll? 
I am actually considering writing my own server for the incoming
SKINI data. But then I needed a detailed protocol of all the exchanged
messages between client-connect and client-disconnect.