IrDAClient Class

Makes connections to services on peer IrDA devices.

Definition

Namespace: InTheHand.Net.Sockets
Assembly: InTheHand.Net.IrDA (in InTheHand.Net.IrDA.dll) Version: 4.0.2+5cdf1cfd21064ea31c5de33d160200ca1c4bc218
C#
public class IrDAClient : IDisposable
Inheritance
Object    IrDAClient
Implements
IDisposable

Remarks

Makes connections to services on peer IrDA devices. It allows discovery of all devices in range, then a connection can be made to the required service on the chosen peer. Or, given just the service name a connection will be made to an arbitrary peer. This is most useful when it is expected that there will be only one device in range—as is often the case.

It can be used with both the full and Compact frameworks, and can be used as a replacement for the latter's built-in version simply by changing the referenced namespace and assembly. It also has features extra to those in the CF's version. For instance, following the pattern of TcpClient in framework version 2, it provides access to the underlying Socket via a Client property. This is particularly useful as it allows setting socket options, for instance IrCOMM Cooked mode with option NineWireMode.

There a number of well-known services, a few are listed here.

  • OBEX file transfer – OBEX:IrXfer, (TinyTP)
  • OBEX general – OBEX, (TinyTP)
  • Printing – IrLPT, IrLMP mode
  • IrCOMM e.g. to modems – IrDA:IrCOMM, IrCOMM 9-Wire/Cooked mode
The modes required by the last two are set by socket option, as noted for IrCOMM above.

Of course the library also includes specific OBEX protocol support, both client and server, see ObexWebRequest etc.

Example

Example code to connect to a IrCOMM service would be as follows.
VB
Public Shared Sub Main()
  Dim cli As New IrDAClient
  ' Set IrCOMM Cooked/9-wire mode.
  cli.Client.SetSocketOption(IrDASocketOptionLevel.IrLmp, _
    IrDASocketOptionName.NineWireMode, _
    1)  ' equivalent to 'True'
  ' Connect
  cli.Connect("IrDA:IrCOMM")
  ' Connected, now send and receive e.g. by using the 
  ' NetworkStream returned by cli.GetStream
  ...
End Sub

Constructors

IrDAClient Initializes a new instance of the IrDAClient class.
IrDAClient(IrDAEndPoint) Initializes a new instance of the IrDAClient class and connects to the specified endpoint.
IrDAClient(String) Initializes a new instance of the IrDAClient class and connects to the specified service name.

Properties

Active Gets or set a value that indicates whether a connection has been made.
Available The number of bytes of data received from the network and available to be read.
Client Gets or sets the underlying Socket.
Connected Gets a value indicating whether the underlying Socket for an IrDAClient is connected to a remote host.
RemoteMachineName Gets the name of the peer device participating in the communication.

Methods

BeginConnect(IrDAEndPoint, AsyncCallback, Object) Begins an asynchronous request for a remote host connection. The remote host is specified by an endpoint.
BeginConnect(String, AsyncCallback, Object) Begins an asynchronous request for a remote host connection. The remote host is specified by a service name (string).
Close Closes the IrDAClient and the underlying connection.
Connect(IrDAEndPoint) Forms a connection to the specified endpoint.
Connect(String) Forms a connection to the specified service on an arbitrary peer.
ConnectAsync Connects the client to the specified service on an arbitrary peer as an asynchronous operation.
DiscoverDevices Obtains information about available devices.
DiscoverDevices(Int32) Obtains information about a specified number of devices.
DiscoverDevices(Int32, Socket) Obtains information about available devices using a socket.
Dispose Closes the IrDAClient and the underlying connection.
Dispose(Boolean) Releases the unmanaged resources used by the IrDAClient and optionally releases the managed resources.
EndConnect Asynchronously accepts an incoming connection attempt.
Equals
(Inherited from Object)
Finalize
(Overrides ObjectFinalize)
GetHashCode
(Inherited from Object)
GetRemoteMachineName Gets the name of the peer device using the specified socket.
GetStream Returns the NetworkStream used to send and receive data.
GetType
(Inherited from Object)
MemberwiseClone
(Inherited from Object)
ToString
(Inherited from Object)

See Also