NetStreams IRDADeviceInfo
 

See also object creation information - ClassID/ProgID 

Overview | Reference | Sample

Overview

The IRDADeviceInfo object is the result holder for IRDA devices lookup. This lookup can be performed by using the SocketStream.GetOption method over initialized but non-connected IRDA socket. See the sample after the members reference.

Remarks: The infrared port communications are usually short connections between devices in the visual range. You cannot be sure if there is a visible device around before performing a lookup. The IRDA addresses are assigned automatically when the devices spot each other. Although there is a cache and the devices will attempt to keep their addresses the same for some time. However there is no guarantee that the device you know of will have the same address the second time it enters the visual range if more than a few minutes have passed. Thus it is recommended to perform lookup each time you need to establish a connection.

Very often the IRDA communication is perceived as peer-to-peer connection. This is not so. If there are more than one devices in the visual range separate connection can be established with each of them. However some devices may have limited capabilities. In Windows by default IRDA stack is limited to 80 sockets, which means that even theoretically you are limited to 80 concurrent IRDA connections. The actual limit may vary depending on the hardware and OS specifics. These limitations usually will not be a problem, but in case of IRDA server applications designed to serve multiple clients the developer should check the platform capabilities more carefully. 

Reference

Address Indexed property.
Syntax:
Set addr = object.Address(n)

addr - A SocketAddress object containing the IRDA address of the device.

n - Index of the device between 1 and Count (1-based index).

Count Syntax:
cnt = object.Count

Returns the count of the IRDA devices found and recorded in this object.

DeviceName Indexed property
Syntax:
name = object.DeviceName(n)

name - the display name of the device

n - Index of the device between 1 and Count (1-based index).

Sample

The sample code is for Windows Scripting Host. WScript.Echo prints output to the console window.

Set socket = CreateObject("newObjects.net.SocketStream")
b = socket.Socket("AF_IRDA","SOCK_STREAM",0)
If Not b Then
    WScript.Echo socket.lastError
    WScript.Quit
End If

Set opt = CreateObject("newObjects.net.SockOpt")
opt.Level = "SOL_IRLMP"
opt.Type = "IRLMP_ENUMDEVICES"
WScript.Echo "Getting option ..."
b = socket.GetOption(opt)
If Not b Then
    WScript.Echo "Error"
    WScript.Echo socket.lastError
    WScript.Quit
End If
Set l = opt.Value
WScript.Echo "Devices: " & l.Count
For I = 1 To l.Count
    WScript.Echo "  " & l.DeviceID(I) & " <-> " & l.DeviceName(I)
Next
socket.Close
newObjects Copyright 2001-2006 newObjects [ ]