From c993e9d31706b2190134813f0a5096a59ad73429 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?IOhannes=20m=20zm=C3=B6lnig?= Date: Wed, 31 Mar 2010 08:58:06 +0000 Subject: output the data of stream-based objects in a serialized form svn path=/trunk/externals/iem/iemnet/; revision=13321 --- iemnet.c | 9 +++++++++ iemnet.h | 14 ++++++++++++++ tcpclient.c | 2 +- tcpreceive.c | 4 ++-- tcpserver.c | 2 +- 5 files changed, 27 insertions(+), 4 deletions(-) diff --git a/iemnet.c b/iemnet.c index 16025cf..aadc90e 100644 --- a/iemnet.c +++ b/iemnet.c @@ -29,6 +29,15 @@ void iemnet__addrout(t_outlet*status_outlet, t_outlet*address_outlet, } +void iemnet__streamout(t_outlet*outlet, int argc, t_atom*argv) { + if(NULL==outlet)return; + while(argc-->0) { + outlet_list(outlet, gensym("list"), 1, argv); + argv++; + } + +} + #ifdef _MSC_VER void tcpclient_setup(void); diff --git a/iemnet.h b/iemnet.h index 3cc21f5..e26fe46 100644 --- a/iemnet.h +++ b/iemnet.h @@ -223,6 +223,20 @@ int iemnet__receiver_getsize(t_iemnet_receiver*); */ void iemnet__addrout(t_outlet*status_outlet, t_outlet*address_outlet, long address, unsigned short port); +/** + * output a list as a stream (serialize) + * + * the given list of atoms will be sent to the output one-by-one + * + * \param outlet outlet to sent the data to + * \param argc size of the list + * \param argv data + * + * \note with stream based protocols (TCP/IP) the length of the received lists has no meaning, so the data has to be serialized anyhow + */ +void iemnet__streamout(t_outlet*outlet, int argc, t_atom*argv); + + #if defined(_MSC_VER) # define snprintf _snprintf # define IEMNET_EXTERN __declspec(dllexport) extern diff --git a/tcpclient.c b/tcpclient.c index dec7983..850736c 100644 --- a/tcpclient.c +++ b/tcpclient.c @@ -215,7 +215,7 @@ static void tcpclient_receive_callback(void*y, t_iemnet_chunk*c, int argc, t_ato if(argc) { iemnet__addrout(x->x_statusout, x->x_addrout, x->x_addr, x->x_port); - outlet_list(x->x_msgout, gensym("list"), argc, argv); + iemnet__streamout(x->x_msgout, argc, argv); } else { // disconnected tcpclient_disconnect(x); diff --git a/tcpreceive.c b/tcpreceive.c index 10b688c..3dc6c9f 100644 --- a/tcpreceive.c +++ b/tcpreceive.c @@ -78,8 +78,8 @@ static void tcpreceive_read_callback(t_tcpconnection *y, int argc, t_atom*argv) if(index>=0) { if(argc) { - // outlet info about connection - outlet_list(x->x_msgout, gensym("list"), argc, argv); + // TODO?: outlet info about connection + iemnet__streamout(x->x_msgout, argc, argv); } else { // disconnected int sockfd=y->socket; diff --git a/tcpserver.c b/tcpserver.c index e611551..d1be424 100644 --- a/tcpserver.c +++ b/tcpserver.c @@ -451,7 +451,7 @@ static void tcpserver_receive_callback(void *y0, if(argc) { tcpserver_info_connection(x, y); - outlet_list(x->x_msgout, gensym("list"), argc, argv); + iemnet__streamout(x->x_msgout, argc, argv); } else { // disconnected int sockfd=y->sr_fd; -- cgit v1.2.1