Socket.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include "os/c-api/il2cpp-config-platforms.h"
  2. #if !RUNTIME_TINY
  3. #include "os/c-api/Socket-c-api.h"
  4. #include "os/c-api/Allocator.h"
  5. #include "os/Socket.h"
  6. #include "utils/Memory.h"
  7. #include <string>
  8. #include <vector>
  9. UnityPalWaitStatus UnityPalGetHostByName(const char* host, char** name, int32_t* family, char*** aliases, void*** address_list, int32_t* address_size)
  10. {
  11. std::string palName;
  12. int32_t palFamily;
  13. std::vector<std::string> palAliases;
  14. std::vector<void*> palAddressList;
  15. int32_t palAddressSize;
  16. il2cpp::os::WaitStatus result = il2cpp::os::Socket::GetHostByName(host, palName, palFamily, palAliases, palAddressList, palAddressSize);
  17. if (name != NULL)
  18. *name = Allocator::CopyToAllocatedStringBuffer(palName.c_str());
  19. if (family != NULL)
  20. *family = palFamily;
  21. Allocator::CopyStringVectorToNullTerminatedArray(palAliases, (void***)aliases);
  22. Allocator::CopyDataVectorToNullTerminatedArray(palAddressList, address_list, palAddressSize);
  23. if (address_size != NULL)
  24. *address_size = palAddressSize;
  25. for (size_t i = 0; i < palAddressList.size(); ++i)
  26. il2cpp::utils::Memory::Free(palAddressList[i]);
  27. return result;
  28. }
  29. #endif