1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef NET_SOCKET_UDP_SERVER_SOCKET_H_ 6 #define NET_SOCKET_UDP_SERVER_SOCKET_H_ 7 8 #include <stdint.h> 9 10 #include "base/macros.h" 11 #include "net/base/completion_once_callback.h" 12 #include "net/base/net_export.h" 13 #include "net/socket/datagram_server_socket.h" 14 #include "net/socket/udp_socket.h" 15 16 namespace net { 17 18 class IPAddress; 19 class IPEndPoint; 20 class NetLog; 21 struct NetLogSource; 22 23 // A server socket that uses UDP as the transport layer. 24 class NET_EXPORT UDPServerSocket : public DatagramServerSocket { 25 public: 26 UDPServerSocket(net::NetLog* net_log, const net::NetLogSource& source); 27 ~UDPServerSocket() override; 28 29 // Implement DatagramServerSocket: 30 int Listen(const IPEndPoint& address) override; 31 int RecvFrom(IOBuffer* buf, 32 int buf_len, 33 IPEndPoint* address, 34 CompletionOnceCallback callback) override; 35 int SendTo(IOBuffer* buf, 36 int buf_len, 37 const IPEndPoint& address, 38 CompletionOnceCallback callback) override; 39 int SetReceiveBufferSize(int32_t size) override; 40 int SetSendBufferSize(int32_t size) override; 41 int SetDoNotFragment() override; 42 void SetMsgConfirm(bool confirm) override; 43 void Close() override; 44 int GetPeerAddress(IPEndPoint* address) const override; 45 int GetLocalAddress(IPEndPoint* address) const override; 46 void UseNonBlockingIO() override; 47 const NetLogWithSource& NetLog() const override; 48 void AllowAddressReuse() override; 49 void AllowBroadcast() override; 50 void AllowAddressSharingForMulticast() override; 51 int JoinGroup(const IPAddress& group_address) const override; 52 int LeaveGroup(const IPAddress& group_address) const override; 53 int SetMulticastInterface(uint32_t interface_index) override; 54 int SetMulticastTimeToLive(int time_to_live) override; 55 int SetMulticastLoopbackMode(bool loopback) override; 56 int SetDiffServCodePoint(DiffServCodePoint dscp) override; 57 void DetachFromThread() override; 58 59 private: 60 UDPSocket socket_; 61 bool allow_address_reuse_; 62 bool allow_broadcast_; 63 bool allow_address_sharing_for_multicast_; 64 DISALLOW_COPY_AND_ASSIGN(UDPServerSocket); 65 }; 66 67 } // namespace net 68 69 #endif // NET_SOCKET_UDP_SERVER_SOCKET_H_ 70