using System;
using System.Net;
using System.Net.Sockets;
using System.IO;
namespace InTheHand.Net.Sockets
{
///
/// An adapter that provides a System.Net.Sockets.Socket-like
/// interface to etc.
///
/// -
///
/// Required as on Widcomm/Broadcom
/// does not support getting a from
/// the property.
/// Motivated by upgrading of to
/// be usable on Widcomm.
///
/// Also adapts , and
/// .
///
///
internal sealed class SocketClientAdapter : SocketStreamIOAdapter
{
readonly BluetoothClient cli1B;
readonly Socket sIT;
public SocketClientAdapter(BluetoothClient cli)
: base(cli.GetStream())
{
cli1B = cli;
}
#if !NO_IRDA
public SocketClientAdapter(IrDAClient cli)
: base(cli.GetStream())
{
sIT = cli.Client;
}
#endif
public SocketClientAdapter(TcpClient cli)
: base(cli.GetStream())
{
sIT = cli.Client;
}
//----
public override EndPoint LocalEndPoint
{
get
{
if (cli1B != null)
// Not ideal!
return new BluetoothEndPoint(BluetoothAddress.None, Guid.Empty);
else
return sIT.LocalEndPoint;
}
}
public override EndPoint RemoteEndPoint
{
get
{
if (cli1B != null)
return cli1B.RemoteEndPoint;
else
return sIT.RemoteEndPoint;
}
}
//
public override int Available
{
get
{
if (cli1B != null)
return cli1B.Available;
else
return sIT.Available;
}
}
}
}