LMMS
Loading...
Searching...
No Matches
juce_Socket.h
Go to the documentation of this file.
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 The code included in this file is provided under the terms of the ISC license
11 http://www.isc.org/downloads/software-support-policy/isc-license. Permission
12 To use, copy, modify, and/or distribute this software for any purpose with or
13 without fee is hereby granted provided that the above copyright notice and
14 this permission notice appear in all copies.
15
16 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
17 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
18 DISCLAIMED.
19
20 ==============================================================================
21*/
22
23namespace juce
24{
25
26//==============================================================================
38{
39public:
40 //==============================================================================
51
54
55 //==============================================================================
61 bool bindToPort (int localPortNumber);
62
74 bool bindToPort (int localPortNumber, const String& localAddress);
75
84 int getBoundPort() const noexcept;
85
94 bool connect (const String& remoteHostname,
95 int remotePortNumber,
96 int timeOutMillisecs = 3000);
97
100
102 void close();
103
106
109
111 bool isLocal() const noexcept;
112
115
116 //==============================================================================
128 int waitUntilReady (bool readyForReading, int timeoutMsecs);
129
140 int read (void* destBuffer, int maxBytesToRead,
141 bool blockUntilSpecifiedAmountHasArrived);
142
150 int write (const void* sourceBuffer, int numBytesToWrite);
151
152 //==============================================================================
166 bool createListener (int portNumber, const String& localHostName = String());
167
177 StreamingSocket* waitForNextConnection() const;
178
179private:
180 //==============================================================================
182 std::atomic<int> portNumber { 0 }, handle { -1 };
183 std::atomic<bool> connected { false }, isListener { false };
185
186 StreamingSocket (const String& hostname, int portNumber, int handle);
187
189};
190
191
192//==============================================================================
204{
205public:
206 //==============================================================================
215 DatagramSocket (bool enableBroadcasting = false);
216
217
220
221 //==============================================================================
230 bool bindToPort (int localPortNumber);
231
243 bool bindToPort (int localPortNumber, const String& localAddress);
244
252 int getBoundPort() const noexcept;
253
256
257 //==============================================================================
269 int waitUntilReady (bool readyForReading, int timeoutMsecs);
270
281 int read (void* destBuffer, int maxBytesToRead,
282 bool blockUntilSpecifiedAmountHasArrived);
283
295 int read (void* destBuffer, int maxBytesToRead,
296 bool blockUntilSpecifiedAmountHasArrived,
297 String& senderIPAddress, int& senderPortNumber);
298
306 int write (const String& remoteHostname, int remotePortNumber,
307 const void* sourceBuffer, int numBytesToWrite);
308
323 void shutdown();
324
325 //==============================================================================
330 bool joinMulticast (const String& multicastIPAddress);
331
336 bool leaveMulticast (const String& multicastIPAddress);
337
342 bool setMulticastLoopbackEnabled (bool enableLoopback);
343
344 //==============================================================================
353 bool setEnablePortReuse (bool enabled);
354
355private:
356 //==============================================================================
357 std::atomic<int> handle { -1 };
358 bool isBound = false;
361 void* lastServerAddress = nullptr;
363
365};
366
367} // namespace juce
#define noexcept
Definition DistrhoDefines.h:72
#define final
Definition DistrhoDefines.h:74
static void shutdown(void)
Definition adplugdb.cpp:297
Definition juce_CriticalSection.h:43
String lastBindAddress
Definition juce_Socket.h:359
void * lastServerAddress
Definition juce_Socket.h:361
String lastServerHost
Definition juce_Socket.h:359
DatagramSocket(bool enableBroadcasting=false)
Definition juce_Socket.cpp:631
bool bindToPort(int localPortNumber)
Definition juce_Socket.cpp:666
int getRawSocketHandle() const noexcept
Definition juce_Socket.h:255
int lastServerPort
Definition juce_Socket.h:360
bool isBound
Definition juce_Socket.h:358
std::atomic< int > handle
Definition juce_Socket.h:357
int getBoundPort() const noexcept
Definition juce_Socket.cpp:688
CriticalSection readLock
Definition juce_Socket.h:362
Definition juce_Socket.h:38
int getPort() const noexcept
Definition juce_Socket.h:108
String hostName
Definition juce_Socket.h:181
CriticalSection readLock
Definition juce_Socket.h:184
const String & getHostName() const noexcept
Definition juce_Socket.h:105
int getBoundPort() const noexcept
Definition juce_Socket.cpp:513
std::atomic< bool > connected
Definition juce_Socket.h:183
std::atomic< int > portNumber
Definition juce_Socket.h:182
StreamingSocket()
Definition juce_Socket.cpp:455
bool bindToPort(int localPortNumber)
Definition juce_Socket.cpp:501
std::atomic< int > handle
Definition juce_Socket.h:182
bool connect(const String &remoteHostname, int remotePortNumber, int timeOutMillisecs=3000)
Definition juce_Socket.cpp:518
bool isConnected() const noexcept
Definition juce_Socket.h:99
int getRawSocketHandle() const noexcept
Definition juce_Socket.h:114
Definition juce_String.h:53
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
#define JUCE_API
Definition juce_StandardHeader.h:152
Definition carla_juce.cpp:31
read(f, &c, 1)
#define const
Definition zconf.h:137