46 return withMember (*
this, &SocketOptions::receiveBufferSize, size);
56 return withMember (*
this, &SocketOptions::sendBufferSize, size);
66 std::optional<int> receiveBufferSize;
67 std::optional<int> sendBufferSize;
109 : options { optionsIn }
121 bool bindToPort (
int localPortNumber);
134 bool bindToPort (
int localPortNumber,
const String& localAddress);
144 int getBoundPort() const noexcept;
154 bool connect (const
String& remoteHostname,
155 int remotePortNumber,
156 int timeOutMillisecs = 3000);
168 int getPort() const noexcept {
return portNumber; }
171 bool isLocal() const noexcept;
188 int waitUntilReady (
bool readyForReading,
int timeoutMsecs);
200 int read (
void* destBuffer,
int maxBytesToRead,
201 bool blockUntilSpecifiedAmountHasArrived);
210 int write (
const void* sourceBuffer,
int numBytesToWrite);
226 bool createListener (
int portNumber,
const String& localHostName =
String());
243 std::atomic<int> portNumber { 0 }, handle { -1 };
244 std::atomic<bool> connected {
false }, isListener {
false };
245 mutable CriticalSection readLock;
247 StreamingSocket (
const String& hostname,
int portNumber,
int handle,
const SocketOptions& options);
249 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (StreamingSocket)
315 bool bindToPort (
int localPortNumber);
328 bool bindToPort (
int localPortNumber,
const String& localAddress);
337 int getBoundPort() const noexcept;
354 int waitUntilReady (
bool readyForReading,
int timeoutMsecs);
366 int read (
void* destBuffer,
int maxBytesToRead,
367 bool blockUntilSpecifiedAmountHasArrived);
380 int read (
void* destBuffer,
int maxBytesToRead,
381 bool blockUntilSpecifiedAmountHasArrived,
382 String& senderIPAddress,
int& senderPortNumber);
391 int write (
const String& remoteHostname,
int remotePortNumber,
392 const void* sourceBuffer,
int numBytesToWrite);
415 bool joinMulticast (
const String& multicastIPAddress);
421 bool leaveMulticast (
const String& multicastIPAddress);
427 bool setMulticastLoopbackEnabled (
bool enableLoopback);
438 bool setEnablePortReuse (
bool enabled);
443 std::atomic<int> handle { -1 };
444 bool isBound =
false;
445 String lastBindAddress, lastServerHost;
446 int lastServerPort = -1;
447 void* lastServerAddress =
nullptr;
448 mutable CriticalSection readLock;
450 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DatagramSocket)
DatagramSocket(bool enableBroadcasting)
int getRawSocketHandle() const noexcept
DatagramSocket(bool enableBroadcasting, const SocketOptions &optionsIn)
SocketOptions withSendBufferSize(int size) const
auto getSendBufferSize() const
SocketOptions withReceiveBufferSize(int size) const
auto getReceiveBufferSize() const
int getPort() const noexcept
const String & getHostName() const noexcept
StreamingSocket(const SocketOptions &optionsIn)
bool isConnected() const noexcept
int getRawSocketHandle() const noexcept