aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2010-03-26 14:35:08 +0000
committerIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2010-03-26 14:35:08 +0000
commitf3c3222c56617c48069d8034a0295306cb8ee4c6 (patch)
treeef8d5a02b42ff0b4a5ec7d19cd07569ae4257c8d
parentc4d13b9652c9b64106e4d809017cbbdfecef2252 (diff)
output server address
svn path=/trunk/externals/iem/iemnet/; revision=13285
-rw-r--r--tcpclient.c13
-rw-r--r--udpclient.c18
2 files changed, 10 insertions, 21 deletions
diff --git a/tcpclient.c b/tcpclient.c
index ef76863..5c396db 100644
--- a/tcpclient.c
+++ b/tcpclient.c
@@ -39,22 +39,20 @@ typedef struct _tcpclient
{
t_object x_obj;
t_clock *x_clock;
- t_clock *x_poll;
t_outlet *x_msgout;
t_outlet *x_addrout;
t_outlet *x_connectout;
t_outlet *x_statusout;
- t_iemnet_sender*x_sender;
+ t_iemnet_sender *x_sender;
t_iemnet_receiver*x_receiver;
int x_fd; // the socket
- char *x_hostname; // address we want to connect to as text
+ char *x_hostname; // address we want to connect to as text
int x_connectstate; // 0 = not connected, 1 = connected
int x_port; // port we're connected to
long x_addr; // address we're connected to as 32bit int
- t_atom x_addrbytes[4]; // address we're connected to as 4 bytes
/* multithread stuff */
@@ -182,6 +180,7 @@ static void tcpclient_receive_callback(void*y, t_iemnet_chunk*c, int argc, t_ato
t_tcpclient *x=(t_tcpclient*)y;
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);
} else {
// disconnected
@@ -203,11 +202,8 @@ static void *tcpclient_new(void)
x->x_fd = -1;
- for (i = 0; i < 4; ++i)
- {
- SETFLOAT(x->x_addrbytes+i, 0);
- }
x->x_addr = 0L;
+ x->x_port = 0;
x->x_sender=NULL;
x->x_receiver=NULL;
@@ -228,7 +224,6 @@ static void *tcpclient_new(void)
static void tcpclient_free(t_tcpclient *x)
{
tcpclient_disconnect(x);
- clock_free(x->x_poll);
clock_free(x->x_clock);
}
diff --git a/udpclient.c b/udpclient.c
index 1a1a2ac..0c72266 100644
--- a/udpclient.c
+++ b/udpclient.c
@@ -1,7 +1,5 @@
/* udpclient.c
* copyright (c) 2010 IOhannes m zmlnig, IEM
- * copyright (c) 2006-2010 Martin Peach
- * copyright (c) 2004 Olaf Matthes
*/
/* */
@@ -39,7 +37,6 @@ typedef struct _udpclient
{
t_object x_obj;
t_clock *x_clock;
- t_clock *x_poll;
t_outlet *x_msgout;
t_outlet *x_addrout;
t_outlet *x_connectout;
@@ -50,11 +47,10 @@ typedef struct _udpclient
int x_fd; // the socket
- char *x_hostname; // address we want to connect to as text
+ char *x_hostname; // address we want to connect to as text
int x_connectstate; // 0 = not connected, 1 = connected
int x_port; // port we're connected to
long x_addr; // address we're connected to as 32bit int
- t_atom x_addrbytes[4]; // address we're connected to as 4 bytes
/* multithread stuff */
@@ -125,6 +121,9 @@ static void *udpclient_child_connect(void *w)
sys_closesocket(sockfd);
return (x);
}
+ x->x_fd = sockfd;
+ x->x_addr = ntohl(*(long *)hp->h_addr);
+
x->x_sender=iemnet__sender_create(sockfd);
x->x_receiver=iemnet__receiver_create(sockfd, x, udpclient_receive_callback);
@@ -190,6 +189,7 @@ static void udpclient_receive_callback(void*y, t_iemnet_chunk*c, int argc, t_ato
t_udpclient *x=(t_udpclient*)y;
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);
} else {
// disconnected
@@ -211,17 +211,12 @@ static void *udpclient_new(void)
x->x_statusout = outlet_new(&x->x_obj, 0);/* last outlet for everything else */
x->x_fd = -1;
-
- for (i = 0; i < 4; ++i)
- {
- SETFLOAT(x->x_addrbytes+i, 0);
- }
x->x_addr = 0L;
+ x->x_port = 0;
x->x_sender=NULL;
x->x_receiver=NULL;
-
x->x_clock = clock_new(x, (t_method)udpclient_tick);
/* prepare child thread */
@@ -237,7 +232,6 @@ static void *udpclient_new(void)
static void udpclient_free(t_udpclient *x)
{
udpclient_disconnect(x);
- clock_free(x->x_poll);
clock_free(x->x_clock);
}