Published on System iNetwork (http://systeminetwork.com)
APIs by Example: List Network Connections (QtocLstNetCnn) API
By tzura
Created Dec 12 2002 - 05:00

One message I see periodically in the newsgroups is a request for sample source code showing how to retrieve the same information that is displayed by the NETSTAT command. With V5R1, this information has been made available via the List Network Connections (QtocLstNetCnn) API, which returns a non- detailed list of all network connections or a subset of all network connections for a specified network connection type.

Bryan Dietz has recently released his free NStat utility, which uses the QtocLstNetCnn API. The utility prompt screen is shown below:
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
                       NStat - OutPut for NetStat (NSTAT)

 Type choices, press Enter.
 Include Listening Ports? . . . . > Y           Y, N
 Output . . . . . . . . . . . . . > *FILE       *PRINT, *FILE
 File Name  . . . . . . . . . . . > FILENAME    Name
   Library  . . . . . . . . . . . >   LIBRARY   Name, *LIBL
 File Option  . . . . . . . . . .   *ADD        Name, *ADD, *REPLACE
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 

If you select the *FILE option, the utility creates a file in the following 
format:

Field Name  Type  Pos  Len Dec
LCLADDR      A     1    15
RMTADDR      A    16    15
LCLPORT      S    31     5  0
RMTPORT      S    36     5  0
BYTESIN      S    41    10  0
BYTESOUT     S    51    10  0
IDLEHOUR     S    61     3  0
IDLEMIN      S    64     2  0
IDELSEC      S    66     2  0
CONNSTAT     A    68    11  
CONNTYPE     A    79    10
OUTPUTTIME   Z    89    26  0

The source for the utility is provided, so you can see for yourself how QtocLstNetCnn is used. You can download the utility from http://home.roadrunner.com/~jbmmdietz/nstat.html [1].

The V5R1 documentation for the QtocLstNetCnn is available at http://publib.boulder.ibm.com/html/as400/v5r1/ic2924/info/apis/qtoclstnetcnn.htm [2].

© 2010 Penton Media, Inc.

Source URL: http://systeminetwork.com/article/apis-example-list-network-connections-qtoclstnetcnn-api

Links:
[1] http://home.roadrunner.com/~jbmmdietz/nstat.html
[2] http://publib.boulder.ibm.com/html/as400/v5r1/ic2924/info/apis/qtoclstnetcnn.htm