mbed socket API
Dependents: EthernetInterface EthernetInterface_RSF EthernetInterface EthernetInterface ... more
Deprecated
This is an mbed 2 sockets library. For mbed 5, network sockets have been revised to better support additional network stacks and thread safety here.
Diff: UDPSocket.cpp
- Revision:
- 16:2d471deff212
- Parent:
- 11:3d83c348fb8b
- Child:
- 18:d56496360fc9
--- a/UDPSocket.cpp Mon Aug 13 09:38:00 2012 +0000
+++ b/UDPSocket.cpp Fri Mar 01 15:30:16 2013 +0000
@@ -49,6 +49,21 @@
return 0;
}
+int UDPSocket::join_multicast_group(const char* address) {
+ struct ip_mreq mreq;
+
+ // Set up group address
+ mreq.imr_multiaddr.s_addr = inet_addr(address);
+ mreq.imr_interface.s_addr = htonl(INADDR_ANY);
+
+ return set_option(IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq));
+}
+
+int UDPSocket::set_broadcasting(void) {
+ int option = 1;
+ return set_option(SOL_SOCKET, SO_BROADCAST, &option, sizeof(option));
+}
+
// -1 if unsuccessful, else number of bytes written
int UDPSocket::sendTo(Endpoint &remote, char *packet, int length) {
if (_sock_fd < 0)
mbed official


