65 bool bindToPort (
int localPortNumber);
78 bool bindToPort (
int localPortNumber,
const String& localAddress);
88 int getBoundPort()
const noexcept;
98 bool connect (
const String& remoteHostname,
100 int timeOutMillisecs = 3000);
112 int getPort() const noexcept {
return portNumber; }
115 bool isLocal() const noexcept;
118 int getRawSocketHandle() const noexcept {
return handle; }
132 int waitUntilReady (
bool readyForReading,
int timeoutMsecs);
144 int read (
void* destBuffer,
int maxBytesToRead,
145 bool blockUntilSpecifiedAmountHasArrived);
154 int write (
const void* sourceBuffer,
int numBytesToWrite);
170 bool createListener (
int portNumber,
const String& localHostName =
String());
186 std::atomic<int> portNumber { 0 }, handle { -1 };
187 std::atomic<bool> connected {
false }, isListener {
false };
188 mutable CriticalSection readLock;
190 StreamingSocket (
const String& hostname,
int portNumber,
int handle);
192 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (StreamingSocket)
234 bool bindToPort (
int localPortNumber);
247 bool bindToPort (
int localPortNumber,
const String& localAddress);
256 int getBoundPort()
const noexcept;
273 int waitUntilReady (
bool readyForReading,
int timeoutMsecs);
285 int read (
void* destBuffer,
int maxBytesToRead,
286 bool blockUntilSpecifiedAmountHasArrived);
299 int read (
void* destBuffer,
int maxBytesToRead,
300 bool blockUntilSpecifiedAmountHasArrived,
301 String& senderIPAddress,
int& senderPortNumber);
310 int write (
const String& remoteHostname,
int remotePortNumber,
311 const void* sourceBuffer,
int numBytesToWrite);
334 bool joinMulticast (
const String& multicastIPAddress);
340 bool leaveMulticast (
const String& multicastIPAddress);
346 bool setMulticastLoopbackEnabled (
bool enableLoopback);
357 bool setEnablePortReuse (
bool enabled);
361 std::atomic<int> handle { -1 };
362 bool isBound =
false;
363 String lastBindAddress, lastServerHost;
364 int lastServerPort = -1;
365 void* lastServerAddress =
nullptr;
366 mutable CriticalSection readLock;
368 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DatagramSocket)
A wrapper for a datagram (UDP) socket.
int getRawSocketHandle() const noexcept
Returns the OS's socket handle that's currently open.
A wrapper for a streaming (TCP) socket.
const String & getHostName() const noexcept
Returns the name of the currently connected host.
int getPort() const noexcept
Returns the port number that's currently open.
bool isConnected() const noexcept
True if the socket is currently connected.
#define JUCE_API
This macro is added to all JUCE public class declarations.