IrDAListener/Client

  • Thread starter Thread starter Jon
  • Start date Start date
J

Jon

Hi,

I'm pretty confused about how to establish a connection
between two pocket pc's over IR. The sort of connection I
want to establish is one in which there's a
irdaclient/socket on each side that can write/read from a
stream to communicate back and forth, similar to a tcp
connection.

The problem is that if I want to construct an
IrDAListener, or just a socket to listen, I usually need
some sort of LOCAL end point to bind to. The concept of a
local endpoint does not not seem to carry over very well
from TCP networking. On a previous post, I was told that
I should use IrDAClient.DiscoverDevices to find a remote
IrDAendpoint to connect too. But, if I do that the
connection will always be refused because there's nothing
accepting connections on the other side.

If anyone has done this sort of thing before, can you
please send me or refer me to some code that does it.
It's not documented AT ALL anywhere, so I have no clue
where to find a solution. I'm especially curious about
the constructor calls for IrDAListener and IrDAClient, or
Sockets.

Thanks for any help you can offer,
Jon
 
Jon,

Here are some C# fragments for an IrDA server and client. You should be
able to connect your devices using this code.

irda server
===========
try
{
byte[] deviceID = { 0, 0, 0, 0 };
string serviceName = "IrDATestServiceName";

listener = new IrDAListener(new IrDAEndPoint(deviceId,
serviceName));

try
{
listener.Start();

while(this.running)
{
try
{
acceptSock = listener.AcceptSocket();
Console.WriteLine("Connection accepted");

//*** add processing code ***
}
catch(SocketException e)
{
Console.WriteLine("Accept faiure -
SocketException " + e.ErrorCode);
throw new ApplicationException();
}
}
}
catch(SocketException e)
{
//*** add processing code ***
}

}
catch(SocketException e)
{
//*** add processing code ***
}

irda client
===========
try
{
// discover nearby devices (find only 1)
IrDADeviceInfo[] Devices = this.Discovery(1);

// connect to the discovered device
IrDAClient client = new IrDAClient();
client.Connect(new IrDAEndPoint(Devices[0].DeviceID,
this.testServerName));

//*** add processing code ***

}
catch(SocketException e)
{
//*** add processing code ***
}

Thanks!
David Kline
Microsoft .NET Compact Framework
--------------------------------
This posting is provided “AS IS” with no warranties, and confers no
rights.

Please do not send email directly to this alias. This alias is for
newsgroup purposes only. To correspond with me directly, remove the
'online' from
my alias.
 
Back
Top