aboutsummaryrefslogtreecommitdiff
path: root/src/netdist.c
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2003-08-29 13:53:51 +0000
committerHans-Christoph Steiner <eighthave@users.sourceforge.net>2003-08-29 13:53:51 +0000
commitde86cb7754d773a2dba3ae92eb0dfc4cb9d77cbd (patch)
treeb84e943785318f49e99423980235c207d2f2435c /src/netdist.c
parentfbc6df8b8cfcf9603df93b02e0625067feebb6f1 (diff)
imported latest version 1.4 direct from Olaf
svn path=/trunk/externals/maxlib/; revision=898
Diffstat (limited to 'src/netdist.c')
-rw-r--r--src/netdist.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/src/netdist.c b/src/netdist.c
index 0c7e55c..a585734 100644
--- a/src/netdist.c
+++ b/src/netdist.c
@@ -29,7 +29,7 @@
#include <sys/types.h>
#include <string.h>
#include <pthread.h>
-#if defined(UNIX) || defined(unix)
+#ifdef UNIX
#include <sys/socket.h>
#include <sys/errno.h>
#include <netinet/in.h>
@@ -67,7 +67,7 @@ static void sys_sockerror(char *s)
int err = WSAGetLastError();
if (err == 10054) return;
#endif
-#if defined(UNIX) || defined(unix)
+#ifdef UNIX
int err = errno;
#endif
post("%s: %s (%d)\n", s, strerror(err), err);
@@ -75,7 +75,7 @@ static void sys_sockerror(char *s)
static void sys_closesocket(int fd) {
-#if defined(UNIX) || defined(unix)
+#ifdef UNIX
close(fd);
#endif
#ifdef NT
@@ -98,10 +98,8 @@ static void *netdist_new(t_floatarg udpflag)
for(i = 0; i < MAX_REC; i++)x->x_fd[i] = -1;
x->x_numconnect = -1;
x->x_protocol = (udpflag != 0 ? SOCK_DGRAM : SOCK_STREAM);
-#ifndef MAXLIB
- post(version);
-#endif
- /* prepare child thread */
+
+ /* prepare child thread */
if(pthread_attr_init(&x->x_threadattr) < 0)
post("netdist: warning: could not prepare child thread" );
if(pthread_attr_setdetachstate(&x->x_threadattr, PTHREAD_CREATE_DETACHED) < 0)
@@ -288,6 +286,7 @@ static void netdist_free(t_netdist *x)
clock_free(x->x_clock);
}
+#ifndef MAXLIB
void netdist_setup(void)
{
netdist_class = class_new(gensym("netdist"), (t_newmethod)netdist_new,
@@ -297,7 +296,20 @@ void netdist_setup(void)
class_addmethod(netdist_class, (t_method)netdist_send, gensym("send"), A_GIMME, 0);
class_addmethod(netdist_class, (t_method)netdist_clear, gensym("clear"), 0);
class_addmethod(netdist_class, (t_method)netdist_print, gensym("print"), 0);
+ class_sethelpsymbol(netdist_class, gensym("help-netdist.pd"));
+ post(version);
}
-
-
-
+#else
+void maxlib_netdist_setup(void)
+{
+ netdist_class = class_new(gensym("maxlib_netdist"), (t_newmethod)netdist_new,
+ (t_method)netdist_free, sizeof(t_netdist), 0, A_DEFFLOAT, 0);
+ class_addcreator((t_newmethod)netdist_new, gensym("netdist"), A_DEFFLOAT, 0);
+ class_addmethod(netdist_class, (t_method)netdist_connect, gensym("connect"), A_SYMBOL, A_FLOAT, 0);
+ class_addmethod(netdist_class, (t_method)netdist_disconnect, gensym("disconnect"), A_SYMBOL, A_FLOAT, 0);
+ class_addmethod(netdist_class, (t_method)netdist_send, gensym("send"), A_GIMME, 0);
+ class_addmethod(netdist_class, (t_method)netdist_clear, gensym("clear"), 0);
+ class_addmethod(netdist_class, (t_method)netdist_print, gensym("print"), 0);
+ class_sethelpsymbol(netdist_class, gensym("maxlib/help-netdist.pd"));
+}
+#endif