sockaddr_storage.h 871 B

1234567891011121314151617181920212223242526272829303132333435
  1. // Copyright 2016 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_BASE_SOCKADDR_STORAGE_H_
  5. #define NET_BASE_SOCKADDR_STORAGE_H_
  6. #include "build/build_config.h"
  7. #if BUILDFLAG(IS_WIN)
  8. #include <winsock2.h>
  9. #include <ws2tcpip.h>
  10. #elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA)
  11. #include <sys/socket.h>
  12. #include <sys/types.h>
  13. #endif
  14. #include "net/base/net_export.h"
  15. namespace net {
  16. // Convenience struct for when you need a |struct sockaddr|.
  17. struct NET_EXPORT SockaddrStorage {
  18. SockaddrStorage();
  19. SockaddrStorage(const SockaddrStorage& other);
  20. void operator=(const SockaddrStorage& other);
  21. struct sockaddr_storage addr_storage;
  22. socklen_t addr_len;
  23. struct sockaddr* const addr;
  24. };
  25. } // namespace net
  26. #endif // NET_BASE_SOCKADDR_STORAGE_H_