You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
2.2 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. #if MYSQL_6_10
  2. // Copyright © 2017 Oracle and/or its affiliates. All rights reserved.
  3. //
  4. // MySQL Connector/NET is licensed under the terms of the GPLv2
  5. // <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
  6. // MySQL Connectors. There are special exceptions to the terms and
  7. // conditions of the GPLv2 as it is applied to this software, see the
  8. // FLOSS License Exception
  9. // <http://www.mysql.com/about/legal/licensing/foss-exception.html>.
  10. //
  11. // This program is free software; you can redistribute it and/or modify
  12. // it under the terms of the GNU General Public License as published
  13. // by the Free Software Foundation; version 2 of the License.
  14. //
  15. // This program is distributed in the hope that it will be useful, but
  16. // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  17. // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  18. // for more details.
  19. //
  20. // You should have received a copy of the GNU General Public License along
  21. // with this program; if not, write to the Free Software Foundation, Inc.,
  22. // 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  23. using System;
  24. using System.Collections.Generic;
  25. using System.Net;
  26. using System.Text;
  27. namespace Externals.MySql.Data.Common
  28. {
  29. [Serializable]
  30. internal class UnixEndPoint : EndPoint
  31. {
  32. public string SocketName { get; private set; }
  33. public UnixEndPoint(string socketName)
  34. {
  35. this.SocketName = socketName;
  36. }
  37. public override EndPoint Create(SocketAddress socketAddress)
  38. {
  39. int size = socketAddress.Size - 2;
  40. byte[] bytes = new byte[size];
  41. for (int i = 0; i < size; i++)
  42. {
  43. bytes[i] = socketAddress[i + 2];
  44. }
  45. return new UnixEndPoint(Encoding.UTF8.GetString(bytes));
  46. }
  47. public override SocketAddress Serialize()
  48. {
  49. byte[] bytes = Encoding.UTF8.GetBytes(SocketName);
  50. SocketAddress socketAddress = new SocketAddress(System.Net.Sockets.AddressFamily.Unix, bytes.Length + 3);
  51. for (int i = 0; i < bytes.Length; i++)
  52. {
  53. socketAddress[i + 2] = bytes[i];
  54. }
  55. return socketAddress;
  56. }
  57. }
  58. }
  59. #endif