OpenShot Audio Library | OpenShotAudio 0.3.2
|
#include <juce_Socket.h>
A wrapper for a datagram (UDP) socket.
This allows low-level use of sockets; for an easier-to-use messaging layer on top of sockets, you could also try the InterprocessConnection class.
Definition at line 203 of file juce_Socket.h.
Creates a datagram socket.
You first need to bind this socket to a port with bindToPort if you intend to read from this socket.
If enableBroadcasting is true, the socket will be allowed to send broadcast messages (may require extra privileges on linux)
Definition at line 633 of file juce_Socket.cpp.
juce::DatagramSocket::~DatagramSocket | ( | ) |
Destructor.
Definition at line 646 of file juce_Socket.cpp.
Binds the socket to the specified local port.
The localPortNumber is the port on which to bind this socket. If this value is 0, the port number is assigned by the operating system.
Definition at line 668 of file juce_Socket.cpp.
Referenced by juce::NetworkServiceDiscovery::AvailableServiceList::AvailableServiceList(), and bindToPort().
Binds the socket to the specified local port and local address.
If localAddress is not an empty string then the socket will be bound to localAddress as well. This is useful if you would like to bind your socket to a specific network adapter. Note that localAddress must be an IP address assigned to one of your network address otherwise this function will fail.
Definition at line 673 of file juce_Socket.cpp.
|
noexcept |
Returns the local port number to which this socket is currently bound.
This is useful if you need to know to which port the OS has actually bound your socket when bindToPort was called with zero.
Definition at line 690 of file juce_Socket.cpp.
|
inlinenoexcept |
Returns the OS's socket handle that's currently open.
Definition at line 255 of file juce_Socket.h.
int juce::DatagramSocket::read | ( | void * | destBuffer, |
int | maxBytesToRead, | ||
bool | blockUntilSpecifiedAmountHasArrived | ||
) |
Reads bytes from the socket.
If blockUntilSpecifiedAmountHasArrived is true, the method will block until maxBytesToRead bytes have been read, (or until an error occurs). If this flag is false, the method will return as much data as is currently available without blocking.
Definition at line 704 of file juce_Socket.cpp.
int juce::DatagramSocket::read | ( | void * | destBuffer, |
int | maxBytesToRead, | ||
bool | blockUntilSpecifiedAmountHasArrived, | ||
String & | senderIPAddress, | ||
int & | senderPortNumber | ||
) |
Reads bytes from the socket and return the IP address of the sender.
If blockUntilSpecifiedAmountHasArrived is true, the method will block until maxBytesToRead bytes have been read, (or until an error occurs). If this flag is false, the method will return as much data as is currently available without blocking.
Definition at line 714 of file juce_Socket.cpp.
Allow other applications to re-use the port.
Allow any other application currently running to bind to the same port. Do not use this if your socket handles sensitive data as it could be read by any, possibly malicious, third-party apps.
Definition at line 776 of file juce_Socket.cpp.
Enables or disables multicast loopback.
Definition at line 768 of file juce_Socket.cpp.
void juce::DatagramSocket::shutdown | ( | ) |
Closes the underlying socket object.
Closes the underlying socket object and aborts any read or write operations. Note that all other methods will return an error after this call and the object cannot be re-used.
This method is useful if another thread is blocking in a read/write call and you would like to abort the read/write thread. Simply deleting the socket object without calling shutdown may cause a race-condition where the read/write returns just before the socket is deleted and the subsequent read/write would try to read from an invalid pointer. By calling shutdown first, the socket object remains valid but all current and subsequent calls to read/write will return immediately.
Definition at line 654 of file juce_Socket.cpp.
Referenced by ~DatagramSocket().
Waits until the socket is ready for reading or writing.
If readyForReading is true, it will wait until the socket is ready for reading; if false, it will wait until it's ready for writing.
If the timeout is < 0, it will wait forever, or else will give up after the specified time.
Definition at line 696 of file juce_Socket.cpp.
int juce::DatagramSocket::write | ( | const String & | remoteHostname, |
int | remotePortNumber, | ||
const void * | sourceBuffer, | ||
int | numBytesToWrite | ||
) |
Writes bytes to the socket from a buffer.
Note that this method will block unless you have checked the socket is ready for writing before calling it (see the waitUntilReady() method).
Definition at line 724 of file juce_Socket.cpp.