/// <summary> /// Creates an endpoint from a socket address. /// </summary> /// <param name="socketAddress"></param> /// <returns></returns> public override EndPoint Create(SocketAddress socketAddress) { if (socketAddress == null) { throw new ArgumentNullException("socketAddress"); } if (socketAddress.Family == AddressFamily) { int ibyte; var socketAddressBytes = socketAddress.ToByteArray(); byte[] addrbytes = new byte[8]; ulong address = BitConverter.ToUInt64(socketAddressBytes, 2); byte[] servicebytes = new byte[16]; for (ibyte = 0; ibyte < 16; ibyte++) { servicebytes[ibyte] = socketAddress[10 + ibyte]; } int port = BitConverter.ToInt32(socketAddressBytes, 26); return(new BluetoothEndPoint(address, new Guid(servicebytes), port)); } return(base.Create(socketAddress)); }