ITK Programmer's Guide


 

Table of contents | Intro | General | TCP Low Level | TCP High Level | UDP | DNS | PPP
Encoding/Decoding | Internet Config | Goodies | Cryptography & SSL | Appendix

 

Chapter 2 : General ITK Routines

   

   

Chapter contents:


About this chapter...

This chapter describes general ITK routines like ITK_Init, which is used to register ITK with its licence key so that it will not run in demo mode.

ITK_TCPInfos provides general information about the TCP/IP layer available on the machine where ITK is used.

Two routines provide global information about the currently used streams (ITK_TCPGetStrm) and the TCP/IP layers (ITK_TCPGlobInfo).

   

   


ITK_Init

Syntax:

result := ITK_Init (registrationCode)


Description:

Register the Internet Toolkit plug-in for standalone or server use.

You must call ITK_Init with a valid registration key, otherwise ITK will operate in demonstration mode - it will cease to function after 20 minutes.


Warning:

Just call this routine once in your application prior to any other call to ITK , otherwise the "demonstration dialog" will show up (the best place to do this is the "On Startup" method).

If you are using ITK in 4D Server's stored procedures, you will have to call ITK_Init at the beginning of the first method called (one call to ITK_Init is enough, you don't need to call it in all stored procedures), otherwise the demonstration dialog will show up on 4D Server.

Multiple calls to ITK_Init are allowed. The plug-in will be activated if at least one valid key is used, and all subsequent calls to ITK_Init will return 0.


Params:

In/Out

Parameter

Type

   

Example or note

->

registrationCode

String

License key

Pass the registration key to register your copy of ITK. Only one registration key is required.
Depending on your license type, the key is either linked to the 4D or 4D Server serial number (individual licenses), or to the machine ID (merged licenses), or to the name of the company/developer (unlimited annual licenses).

<-

result

Longint

Registration error code

0 = no registration error
1 = Beta license has expired
2 = Invalid license
3 = The license has expired
4 = The OEM license has expired)
5 = The maximum number of users has been exceeded
6 = The license is for a different environment (e.g. the licence is for a single-user version, but you are using it with 4D Server)
7 = The license is linked to a different 4D license
8 = Invalid merged license


Example:

C_LONGINT ($result)
$result:=ITK_Init ("YourRegistrationKey")
Case of
:($result=2)
ALERT ("The ITK licence is invalid.")
:($result=3)
ALERT ("The ITK licence has expired.")
etc.
End case
Back to top


ITK_TCPInfos

Syntax:

result := ITK_TCPInfos (localIP; version1; version2; ITKversion)


Description:

Returns global information about the TCP/IP layers.


Params:

In/Out

Parameter

Type

   

Example or note

<-

localIP

Longint

local IP address

On multihomed systems, the primary (or default) local IP address is returned.

<-

version1

Longint

version of TCP/IP layers

1 = MacTCP 1.1
2 = MacTCP 1.1.1
3 = MacTCP 2.0.x
4 = TCP/IP (MacOS)
5 = Winsock

<-

version2

Longint

OpenTransport's version number

This parameter is deprecated on MacOS X 10.9 and above.
Under OpenTransport (pre-MacOS X 10.9), returns OpenTransport's version code. OpenTransport version codes are values returned by Gestalt selector 'otvr' with Apple's standard version format.
$MMmrssbb (in hexadecimal) where:

  • MM = major version number
  • m = minor version number
  • r = release version number
  • ss = stage code ($20 = dev, $40 = alpha, $60 = beta, $80 = Final)
  • bb = build number

For example, OpenTransport 1.1 returns 17858560 decimal, which is $01108000 in hexadecimal so this is version 1.1F.

<-

ITKversion

Longint

ITK's version number

Same format as Apple's standard version format (see above).

<-

result

Longint

error code (negative values).

   


Example:

$err := ITK_TCPInfos(locAddr;TCPvers;OTvers)
if (TCPvers=5) ` we're under Windows
foldSep := "\"
else
foldSep := ":"
end if
 
Back to top


ITK_TCPGetStrm

Syntax:

result := ITK_TCPGetStrm (index)


Description:

This routine allows to retrieve the list of all current TCP streams allocated by ITK.


Params:

In/Out

Parameter

Type

   

Example or note

->

index

Longint

Index value

Pass 0 to get the current number of streams.
Pass 1..n to get the Nth stream.

<-

result

Longint

StreamRef (if index > 0)
number of streams (if index=0)
0 (index out of range)

If index > 0 returns the StreamRef.
If index = 0 returns the amount of allocated streams
If the returned value is 0 the index is out of range.


Example:

$nbStrm := ITK_TCPGetStrm(0) ` get the number of allocated streams
For ($i;1;$nbStrm)
$status := ITK_TCPStatus(ITK_TCPGetStrm($i))
End For
 
Back to top


ITK_TCPGlobInfo

Syntax:

result := ITK_TCPGlobInfo (infoSelector)


Description:

Returns global information about the TCP layers.


Params:

In/Out

Parameter

Type

   

Example or note

->

 

infoSelector

 

Longint

 

global info selector

Global info selectors:

  • 1 = round trip average *
  • 2 = minimum round trip time *
  • 3 = maximum round trip time *
  • 4 = maximum TCP segment size *
  • 5 = maximum TCP connections
  • 6 = number of connection attempts
  • 7 = number of connections opened
  • 8 = number of connections accepted
  • 9 = number of closed connections
  • 10 = number of aborted connections
  • 11 = bytes received**
  • 12 = bytes sent**
  • 13 = duplicate bytes received *
  • 14 = retransmitted bytes *
  • 15 = number of packets received *
  • 16 = number of packets sent *
  • 17 = number of duplicate packets received *
  • 18 = number of packets retransmitted *

* this information is only available under MacTCP.

** With SSL streams, the number of "raw" bytes transmitted is used.

<-

 

result

 

Longint

 

returned value

   


Example:

maxTCPstrm := ITK_TCPGlobInfo(5) ` max. number of streams
Back to top


e-Node/19 February 2014