Add basic UDP multicast support.
This also adds a new setOption method to handle boolean socket options in a generic way.
This commit is contained in:
parent
166ccfe861
commit
06c6e0a4ca
3 changed files with 141 additions and 0 deletions
|
@ -278,6 +278,9 @@ interface EventDriverSockets {
|
|||
/// Sets the `SO_BROADCAST` socket option.
|
||||
bool setBroadcast(DatagramSocketFD socket, bool enable);
|
||||
|
||||
/// Joins the multicast group associated with the given IP address.
|
||||
bool joinMulticastGroup(DatagramSocketFD socket, scope Address multicast_address);
|
||||
|
||||
/// Receives a single datagram.
|
||||
void receive(DatagramSocketFD socket, ubyte[] buffer, IOMode mode, DatagramIOCallback on_receive_finish);
|
||||
/// Cancels an ongoing wait for an incoming datagram.
|
||||
|
@ -301,6 +304,12 @@ interface EventDriverSockets {
|
|||
*/
|
||||
bool releaseRef(SocketFD descriptor);
|
||||
|
||||
/** Enables or disables a socket option.
|
||||
*/
|
||||
bool setOption(DatagramSocketFD socket, DatagramSocketOption option, bool enable);
|
||||
/// ditto
|
||||
bool setOption(StreamSocketFD socket, StreamSocketOption option, bool enable);
|
||||
|
||||
/// Low-level user data access. Use `getUserData` instead.
|
||||
protected void* rawUserData(StreamSocketFD descriptor, size_t size, DataInitializer initialize, DataInitializer destroy) @system;
|
||||
/// ditto
|
||||
|
@ -561,6 +570,16 @@ enum StreamListenOptions {
|
|||
reusePort = 1<<0,
|
||||
}
|
||||
|
||||
enum StreamSocketOption {
|
||||
noDelay,
|
||||
keepAlive
|
||||
}
|
||||
|
||||
enum DatagramSocketOption {
|
||||
broadcast,
|
||||
multicastLoopback
|
||||
}
|
||||
|
||||
/**
|
||||
Specifies how a file is manipulated on disk.
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue