udp_server_socket.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. #ifndef NET_SOCKET_UDP_SERVER_SOCKET_H_
  5. #define NET_SOCKET_UDP_SERVER_SOCKET_H_
  6. #include <stdint.h>
  7. #include "net/base/completion_once_callback.h"
  8. #include "net/base/net_export.h"
  9. #include "net/socket/datagram_server_socket.h"
  10. #include "net/socket/udp_socket.h"
  11. namespace net {
  12. class IPAddress;
  13. class IPEndPoint;
  14. class NetLog;
  15. struct NetLogSource;
  16. // A server socket that uses UDP as the transport layer.
  17. class NET_EXPORT UDPServerSocket : public DatagramServerSocket {
  18. public:
  19. UDPServerSocket(net::NetLog* net_log, const net::NetLogSource& source);
  20. UDPServerSocket(const UDPServerSocket&) = delete;
  21. UDPServerSocket& operator=(const UDPServerSocket&) = delete;
  22. ~UDPServerSocket() override;
  23. // Implement DatagramServerSocket:
  24. int Listen(const IPEndPoint& address) override;
  25. int RecvFrom(IOBuffer* buf,
  26. int buf_len,
  27. IPEndPoint* address,
  28. CompletionOnceCallback callback) override;
  29. int SendTo(IOBuffer* buf,
  30. int buf_len,
  31. const IPEndPoint& address,
  32. CompletionOnceCallback callback) override;
  33. int SetReceiveBufferSize(int32_t size) override;
  34. int SetSendBufferSize(int32_t size) override;
  35. int SetDoNotFragment() override;
  36. void SetMsgConfirm(bool confirm) override;
  37. void Close() override;
  38. int GetPeerAddress(IPEndPoint* address) const override;
  39. int GetLocalAddress(IPEndPoint* address) const override;
  40. void UseNonBlockingIO() override;
  41. const NetLogWithSource& NetLog() const override;
  42. void AllowAddressReuse() override;
  43. void AllowBroadcast() override;
  44. void AllowAddressSharingForMulticast() override;
  45. int JoinGroup(const IPAddress& group_address) const override;
  46. int LeaveGroup(const IPAddress& group_address) const override;
  47. int SetMulticastInterface(uint32_t interface_index) override;
  48. int SetMulticastTimeToLive(int time_to_live) override;
  49. int SetMulticastLoopbackMode(bool loopback) override;
  50. int SetDiffServCodePoint(DiffServCodePoint dscp) override;
  51. void DetachFromThread() override;
  52. private:
  53. UDPSocket socket_;
  54. bool allow_address_reuse_ = false;
  55. bool allow_broadcast_ = false;
  56. bool allow_address_sharing_for_multicast_ = false;
  57. };
  58. } // namespace net
  59. #endif // NET_SOCKET_UDP_SERVER_SOCKET_H_