NetStreams SockOpt
 

See also object creation information - ClassID/ProgID 

Overview | Reference

Overview

The SockOpt object is used for setting/getting a socket option. This is done through the GetOption and SetOption methods of the SocketStream object. Because the option values vary in type this object is intended to deal with this. 

Currently only part of the options are supported. In most cases you will not need to use this feature (note also that some options are accessible through special properties), but there are certain circumstances in which you may need to query or set options. One good example is the IRDA lookup for devices (See the sample at the bottom of the page). 

The usage of an option follows this pattern:

1. The level and the type of the option are set. Use the Level and the Type properties - put in them the constants/key names for the option you need. With this the SockOpt object is configured and "knows" the option's specific value type, and if the option is readable or/and writable.

2. If the option will be set to a socket, its value must be set. Pass the value to the Value property.

3. Use the GetOption or SetOption methods over a SocketStream to perform the operation.

4. If the operation is successful continue, if not check the SocketStream object's LastError for the error text.

5. If the options has been read (GetOption has been used) you may now consult the option's value by reading the SockOpt's Value property.

Reference

Level Syntax:
v = object.Level
object.Level = v

The option level. Default is socket. See Constants and names for the possible values.

When read returns the name of the option level. To read the option level code as number use LevelCode

LevelCode Syntax:
v = object.LevelCode

Returns the numeric value of the option level.

Type Syntax:
v = object.Type
object.Type = v

The option type. See Constants and names for the possible values.

When read returns the name of the option type. To read the option type code as number use TypeCode

TypeCode Syntax:
v = object.TypeCode

Returns the numeric value of the option type.

Value Syntax:
object.Value = v
v = object.Value
Set v = object.Value

Set/Get the option value. Depending on the options type (and level) the value type varies. See the table on the Constants and names page.

Readable Syntax:
v = object.Readable

b - Boolean. Indicates if the option can be read. The level and the option type must be set before referring to this property.

Writable Syntax:
v = object.Readable

b - Boolean. Indicates if the option can be written. The level and the option type must be set before referring to this property.

method.gif (107 bytes) GetBinValueData Used internally. Can be helpful when used in C++.
Syntax:
v = object.GetBinValueData

Returns the option value as array of bytes packed in VARIANT (VT_UI1 | VT_ARRAY)

method.gif (107 bytes) PutBinValueData Used internally. Can be helpful when used in C++.
Syntax:
object.PutBinValueData(v)

Sets the option value as array of bytes packed in VARIANT (VT_UI1 | VT_ARRAY)

OptionalSize Syntax:
v = object.OptionalSize
object.OptionalSize = v

v - Numeric value, by default it is 0. If set to value different from 0 it specifies the optional size of a buffer, maximum elements applicable for certain options (see below). If set to 0 the option will use the default maximum/size.

Current support for:
IRLMP_ENUMDEVICES - Specifies the maximum number of devices that can be found in the vicinity while performing lookup. The default maximum is 10. 

RequiredBuffer Mostly for internal usage. Can be of some use in C++ applications.
Syntax:
v = object.RequiredBuffer

v - Long. Returns the size of the buffer required for the option. The size is calculated over the option level, type and (if applicable) the optional size. Therefore they must be set before referring to this property.

...

newObjects Copyright 2001-2006 newObjects [ ]