UAddress.cs 492 B

123456789101112131415161718192021222324252627
  1. using System;
  2. using System.Net;
  3. namespace Base
  4. {
  5. internal struct UAddress
  6. {
  7. private readonly uint ip;
  8. private readonly ushort port;
  9. public UAddress(string host, int port)
  10. {
  11. IPAddress address = IPAddress.Parse(host);
  12. this.ip = BitConverter.ToUInt32(address.GetAddressBytes(), 0);
  13. this.port = (ushort) port;
  14. }
  15. public ENetAddress Struct
  16. {
  17. get
  18. {
  19. ENetAddress address = new ENetAddress { Host = this.ip, Port = this.port };
  20. return address;
  21. }
  22. }
  23. }
  24. }