Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(531)

Unified Diff: net/udp/udp_socket_win.h

Issue 10739002: Added broadcasting feature to UDP server sockets. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixed license headers. Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/udp/udp_socket_win.h
diff --git a/net/udp/udp_socket_win.h b/net/udp/udp_socket_win.h
index bd47496ee81048ab60f783076c26d5bce17a2002..a82860fbeea67c68956490c84a90baac9f2577e6 100644
--- a/net/udp/udp_socket_win.h
+++ b/net/udp/udp_socket_win.h
@@ -105,7 +105,22 @@ class NET_EXPORT UDPSocketWin : NON_EXPORTED_BASE(public base::NonThreadSafe) {
const BoundNetLog& NetLog() const { return net_log_; }
+ // Sets corresponding flags in |socket_options_| to allow the socket
+ // to share the local address to which socket will be bound with
+ // other processes. Should be called before Bind().
+ void AllowAddressReuse();
+
+ // Sets corresponding flags in |socket_options_| to allow sending
+ // and receiving packets sent to and from broadcast
+ // addresses. Should be called before Bind().
+ void AllowBroadcast();
+
private:
+ enum SocketOptions {
+ SOCKET_OPTION_REUSE_ADDRESS = 1 << 0,
+ SOCKET_OPTION_BROADCAST = 1 << 1
+ };
+
class ReadDelegate : public base::win::ObjectWatcher::Delegate {
public:
explicit ReadDelegate(UDPSocketWin* socket) : socket_(socket) {}
@@ -156,6 +171,9 @@ class NET_EXPORT UDPSocketWin : NON_EXPORTED_BASE(public base::NonThreadSafe) {
int InternalRecvFrom(IOBuffer* buf, int buf_len, IPEndPoint* address);
int InternalSendTo(IOBuffer* buf, int buf_len, const IPEndPoint* address);
+ // Applies |socket_options_| to |socket_|. Should be called before
+ // Bind().
+ int SetSocketOptions();
int DoBind(const IPEndPoint& address);
int RandomBind(const IPEndPoint& address);
@@ -165,6 +183,10 @@ class NET_EXPORT UDPSocketWin : NON_EXPORTED_BASE(public base::NonThreadSafe) {
SOCKET socket_;
+ // Bitwise-or'd combination of SocketOptions. Specifies set of
+ // options that should be applied to |socket_| before bind.
+ int socket_options_;
+
// How to do source port binding, used only when UDPSocket is part of
// UDPClientSocket, since UDPServerSocket provides Bind.
DatagramSocket::BindType bind_type_;

Powered by Google App Engine
This is Rietveld 408576698