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 "net/base/completion_callback.h" 9#include "net/base/net_util.h" 10#include "net/udp/datagram_server_socket.h" 11#include "net/udp/udp_socket.h" 12 13namespace net { 14 15class IPEndPoint; 16class BoundNetLog; 17 18// A client socket that uses UDP as the transport layer. 19class NET_EXPORT UDPServerSocket : public DatagramServerSocket { 20 public: 21 UDPServerSocket(net::NetLog* net_log, 22 const net::NetLog::Source& source); 23 virtual ~UDPServerSocket(); 24 25 // Implement DatagramServerSocket: 26 virtual int Listen(const IPEndPoint& address) OVERRIDE; 27 virtual int RecvFrom(IOBuffer* buf, 28 int buf_len, 29 IPEndPoint* address, 30 const CompletionCallback& callback) OVERRIDE; 31 virtual int SendTo(IOBuffer* buf, 32 int buf_len, 33 const IPEndPoint& address, 34 const CompletionCallback& callback) OVERRIDE; 35 virtual bool SetReceiveBufferSize(int32 size) OVERRIDE; 36 virtual bool SetSendBufferSize(int32 size) OVERRIDE; 37 virtual void Close() OVERRIDE; 38 virtual int GetPeerAddress(IPEndPoint* address) const OVERRIDE; 39 virtual int GetLocalAddress(IPEndPoint* address) const OVERRIDE; 40 virtual const BoundNetLog& NetLog() const OVERRIDE; 41 virtual void AllowAddressReuse() OVERRIDE; 42 virtual void AllowBroadcast() OVERRIDE; 43 virtual int JoinGroup(const IPAddressNumber& group_address) const OVERRIDE; 44 virtual int LeaveGroup(const IPAddressNumber& group_address) const OVERRIDE; 45 virtual int SetMulticastTimeToLive(int time_to_live) OVERRIDE; 46 virtual int SetMulticastLoopbackMode(bool loopback) OVERRIDE; 47 48 private: 49 UDPSocket socket_; 50 DISALLOW_COPY_AND_ASSIGN(UDPServerSocket); 51}; 52 53} // namespace net 54 55#endif // NET_SOCKET_UDP_SERVER_SOCKET_H_ 56