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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 #include <sys/types.h>
27 # include <winsock2.h>
29 # include <sys/socket.h>
31 #include "OSC_Packet.h"
34 //////////////////////////////////////////////////////////////////////////////////////////////////////////
43 virtual ReplyFunc
GetReplyFunc()=0;
45 SC_CmdPort(struct World
*inWorld
);
46 virtual ~SC_CmdPort() {}
48 virtual void* Run()=0;
51 //////////////////////////////////////////////////////////////////////////////////////////////////////////
53 class SC_ComPort
: public SC_CmdPort
58 struct sockaddr_in mBindSockAddr
;
61 pthread_t mRendezvousThread
;
65 SC_ComPort(struct World
*inWorld
, int inPortNum
);
66 virtual ~SC_ComPort();
68 int Socket() { return mSocket
; }
70 int PortNum() const { return mPortNum
; }
72 // default implementation does nothing (this is correct for
73 // SC_TcpConnectionPort). Subclasses may override.
74 virtual void PublishToRendezvous() { };
78 //////////////////////////////////////////////////////////////////////////////////////////////////////////
80 const size_t kMaxUDPSize
= 65535;
82 class SC_UdpInPort
: public SC_ComPort
85 struct sockaddr_in mReplySockAddr
;
86 unsigned char mReadBuf
[kMaxUDPSize
];
87 virtual ReplyFunc
GetReplyFunc();
90 SC_UdpInPort(struct World
*inWorld
, int inPortNum
);
93 int PortNum() const { return mPortNum
; }
97 virtual void PublishToRendezvous();
102 //////////////////////////////////////////////////////////////////////////////////////////////////////////
104 class SC_TcpInPort
: public SC_ComPort
106 SC_Semaphore mConnectionAvailable
;
110 virtual ReplyFunc
GetReplyFunc();
113 SC_TcpInPort(struct World
*inWorld
, int inPortNum
, int inMaxConnections
, int inBacklog
);
117 void ConnectionTerminated();
118 #ifdef USE_RENDEZVOUS
119 virtual void PublishToRendezvous();
123 //////////////////////////////////////////////////////////////////////////////////////////////////////////
125 class SC_TcpConnectionPort
: public SC_ComPort
127 SC_TcpInPort
*mParent
;
128 unsigned char mReadBuf
[kMaxUDPSize
];
131 virtual ReplyFunc
GetReplyFunc();
134 SC_TcpConnectionPort(struct World
*inWorld
, SC_TcpInPort
*inParent
, int inSocket
);
135 virtual ~SC_TcpConnectionPort();