[muscle] Re: muscle client

  • From: "Jeremy Friesner" <jaf@xxxxxxxxxxxx>
  • To: "Lode Vandevenne" <lode@xxxxxxxxxxxxxxxx>
  • Date: Sat, 16 Oct 2004 08:42:00 PDT (-0700)

Hi Lode,

If you are looking for simplicity, you have a couple of options:

1) You can link in just the Message.cpp, String.cpp, ByteBuffer.cpp, 
SysLog.cpp, AbstractMessageIOGateway.cpp, MessageIOGateway.cpp, PulseNode.cpp, 
SetupSystem.cpp, and NetworkUtilityFunctions.cpp files (and maybe a couple of 
others that I forgot here) and handle all the data sending/receiving yourself.  
To do this you would just manually connect to the server (you can do this in 
one line by calling Connect() function in NetworkUtilityFunctions), then give 
the TCP socket to a TCPSocketDataIO object, and then pass the TCPSocketDataIO 
object to your MessageIOGateway object.  Then you just call DoInput(), 
DoOutput(), and AddOutgoingMessage() on the MessageIOGateway object to handle 
input and output. To handle i/o multiplexing you would call select() yourself 
to determine whether the socket is ready to read or write... or if your needs 
are quite trivial, you might be able to get away with blocking I/O (note that 
you won't be able to send and receive simultaneously if you do that!
 , though).  See the test program muscle/test/testresponse.cpp for an example 
of this strategy.  Also, if you aren't doing any multithreading, you can set 
the  MUSCLE=5FSINGLE=5FTHREAD=5FONLY compiler flag in your project file, and 
that will make the code a bit more efficient (since it won't have to do any 
mutex locking/unlocking)

or if that is still too much, you could...

2) Use the new C-only MiniMessage API -- with this API you only need to link in 
MiniMessage.c and MiniMessageGateway.c.  This API is a very small amount of 
code (less than 30KB added to the executable size in my experience) but note 
that it hasn't been extensively field-tested so there might be some 
undiscovered bugs.  The algorithm you would use is essentially the same as in 
(1), except that the API is C-only, which makes it a bit less 
programmer-friendly to use.  See test/minireflectclient.c for an example of 
doing this.  (Note that you need v2.60 of MUSCLE to use MiniMessage)

Hope that helps,
Jeremy

> Hi,
> 
> is it possible to make a server that uses muscle, but make the client
> *without* linking it to the muscle library, and instead code everything to
> handle sending and receiving messages to and from the muscle server
> manually=3F Or does the muscle server use such a complex data type that we
> really need to link the code of the client to the muscle library=3F
> 
> It would be nice if we could program the server with the muscle library in
> Linux to use all it's possibilities, while we can use our own code for the
> client without having to link it to the
> super-complex-way-too-hard-to-use-in-windows-linker-error-giving library :)



Other related posts: