2 SuperCollider real time audio synthesis system
3 Copyright (c) 2002 James McCartney. All rights reserved.
4 http://www.audiosynth.com
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #if defined (__APPLE__) && defined (__GNUC__)
26 #define USE_RENDEZVOUS
29 #include <sys/types.h>
31 # include <winsock2.h>
33 # include <sys/socket.h>
35 #include "OSC_Packet.h"
38 //////////////////////////////////////////////////////////////////////////////////////////////////////////
47 virtual ReplyFunc
GetReplyFunc()=0;
49 SC_CmdPort(struct World
*inWorld
);
50 virtual ~SC_CmdPort() {}
52 virtual void* Run()=0;
55 //////////////////////////////////////////////////////////////////////////////////////////////////////////
57 class SC_ComPort
: public SC_CmdPort
62 struct sockaddr_in mBindSockAddr
;
65 pthread_t mRendezvousThread
;
69 SC_ComPort(struct World
*inWorld
, int inPortNum
);
70 virtual ~SC_ComPort();
72 int Socket() { return mSocket
; }
74 int PortNum() const { return mPortNum
; }
76 // default implementation does nothing (this is correct for
77 // SC_TcpConnectionPort). Subclasses may override.
78 virtual void PublishToRendezvous() { };
82 //////////////////////////////////////////////////////////////////////////////////////////////////////////
84 const size_t kMaxUDPSize
= 65535;
86 class SC_UdpInPort
: public SC_ComPort
89 struct sockaddr_in mReplySockAddr
;
90 unsigned char mReadBuf
[kMaxUDPSize
];
91 virtual ReplyFunc
GetReplyFunc();
94 SC_UdpInPort(struct World
*inWorld
, int inPortNum
);
97 int PortNum() const { return mPortNum
; }
100 #ifdef USE_RENDEZVOUS
101 virtual void PublishToRendezvous();
106 //////////////////////////////////////////////////////////////////////////////////////////////////////////
108 class SC_TcpInPort
: public SC_ComPort
110 SC_Semaphore mConnectionAvailable
;
114 virtual ReplyFunc
GetReplyFunc();
117 SC_TcpInPort(struct World
*inWorld
, int inPortNum
, int inMaxConnections
, int inBacklog
);
121 void ConnectionTerminated();
122 #ifdef USE_RENDEZVOUS
123 virtual void PublishToRendezvous();
127 //////////////////////////////////////////////////////////////////////////////////////////////////////////
129 class SC_TcpConnectionPort
: public SC_ComPort
131 SC_TcpInPort
*mParent
;
132 unsigned char mReadBuf
[kMaxUDPSize
];
135 virtual ReplyFunc
GetReplyFunc();
138 SC_TcpConnectionPort(struct World
*inWorld
, SC_TcpInPort
*inParent
, int inSocket
);
139 virtual ~SC_TcpConnectionPort();
144 //////////////////////////////////////////////////////////////////////////////////////////////////////////
148 #include <CoreFoundation/CFMessagePort.h>
150 class SC_MachMessagePort
: public SC_CmdPort
152 CFMessagePortRef mServerPort
;
153 CFMessagePortRef mReplyPort
;
156 virtual ReplyFunc
GetReplyFunc();
159 SC_MachMessagePort(struct World
*inWorld
, CFStringRef serverPortName
, CFStringRef replyPortName
);
160 virtual ~SC_MachMessagePort();
165 static CFDataRef
messagePortCallBack(CFMessagePortRef local
, SInt32 msgid
, CFDataRef data
, void *info
);
170 //////////////////////////////////////////////////////////////////////////////////////////////////////////