Chromium Code Reviews| Index: net/udp/udp_socket_libevent.h |
| diff --git a/net/udp/udp_socket_libevent.h b/net/udp/udp_socket_libevent.h |
| index ce8a0f2269ad4c39dbe6f8b7e997216ecebde42a..c6dd6ade39cfec6e9c4fc0ae7e1d9fc18b37574f 100644 |
| --- a/net/udp/udp_socket_libevent.h |
| +++ b/net/udp/udp_socket_libevent.h |
| @@ -113,12 +113,40 @@ class NET_EXPORT UDPSocketLibevent : public base::NonThreadSafe { |
| // called before Bind(). |
| void AllowBroadcast(); |
| + // Join the multicast group. |
| + // |group_address| is the group address to join, could be either |
| + // an IPv4 or IPv6 address. |
| + // Return a network error code. |
| + int JoinGroup(const IPAddressNumber& group_address) const; |
| + |
| + // Leave the multicast group. |
| + // |group_address| is the group address to leave, could be either |
| + // an IPv4 or IPv6 address. If the socket hasn't joined the group, |
| + // it will be ignored. |
| + // It's optional to leave the multicast group before destroying |
| + // the socket. It will be done by the OS. |
| + // Return a network error code. |
| + int LeaveGroup(const IPAddressNumber& group_address) const; |
| + |
| + // Set the time-to-live option for UDP packets sent to the multicast |
| + // group address. The default value of this option is 1. |
| + // Cannot be negative or more than 255. |
| + // Should be called before Bind(). |
|
wtc
2013/04/17 22:06:50
Add: Return a network error code.
Bei Zhang
2013/04/19 19:40:14
Done.
|
| + int SetMulticastTimeToLive(int time_to_live); |
| + |
| + // Set the loopback flag for UDP socket. If this flag is true, the host |
| + // will receive packets sent to the joined group from itself. |
| + // The default value of this option is true. |
| + // Should be called before Bind(). |
| + int SetMulticastLoopbackMode(bool loopback); |
| + |
| private: |
| static const int kInvalidSocket = -1; |
| enum SocketOptions { |
| - SOCKET_OPTION_REUSE_ADDRESS = 1 << 0, |
| - SOCKET_OPTION_BROADCAST = 1 << 1 |
| + SOCKET_OPTION_REUSE_ADDRESS = 1 << 0, |
| + SOCKET_OPTION_BROADCAST = 1 << 1, |
| + SOCKET_OPTION_MULTICAST_LOOP = 1 << 2 |
| }; |
| class ReadWatcher : public MessageLoopForIO::Watcher { |
| @@ -188,11 +216,16 @@ class NET_EXPORT UDPSocketLibevent : public base::NonThreadSafe { |
| int RandomBind(const IPEndPoint& address); |
| int socket_; |
| + int addr_family_; |
| // Bitwise-or'd combination of SocketOptions. Specifies the set of |
| // options that should be applied to |socket_| before Bind(). |
| int socket_options_; |
| + // Multicast socket options cached for SetSocketOption. |
| + // Cannot be used after Bind(). |
|
wtc
2013/04/17 22:06:50
"Cannot be used after Bind()": Is this still true?
Bei Zhang
2013/04/19 19:40:14
Yes, it's true this time (it wasn't). If write to
|
| + int multicast_time_to_live_; |
| + |
| // How to do source port binding, used only when UDPSocket is part of |
| // UDPClientSocket, since UDPServerSocket provides Bind. |
| DatagramSocket::BindType bind_type_; |