Retrieve Network Connection Data (QtocRtvNetCnnDta) API

  Required Parameter Group:


  Service Program: QTOCNETSTS

  Threadsafe: Yes

The Retrieve Network Connection Data (QtocRtvNetCnnDta) API retrieves detailed information about a specified IPv4 or IPv6 network connection, including jobs using the connection. It also retrieves information about IPv4 and IPv6 connection totals.

TCP/IP must be active on this system, otherwise, TCP84C0 message will be issued.

The QSYS2.NETSTAT_INFO and QSYS2.NETSTAT_JOB_INFO views can be used as alternatives to this API. See NETSTAT_INFO view and NETSTAT_JOB_INFO view for more information.


Authorities and Locks

None.


Required Parameter Group

Receiver variable
OUTPUT; CHAR(*)

The variable that is to receive the information requested. You can specify the size of this area to be smaller than the format requested if you specify the length of receiver variable parameter correctly. As a result, the API returns only the data that the area can hold.

Length of receiver variable
INPUT; BINARY(4)

The length of the receiver variable. If this value is larger than the actual size of the receiver variable, the result may not be predictable. The minimum length is 8 bytes.

Format name
INPUT; CHAR(8)

The format of the space information to be returned. The format names supported are:


Socket connection request
INPUT; CHAR(*)

The protocol, local address, local port, remote address and remote port identify the connection for which information is to be retrieved. This parameter is ignored when format NCND0100 or format NCND1100 is requested. See Socket Connection Request Format for details on the format.

Error code
I/O; CHAR(*)

The structure in which to return error information. For the format of the structure, see Error code parameter.


Socket Connection Request Format

Information passed in the socket connection request parameter must be in one of the following two formats. The first format is for IPv4 connections, and the second is for IPv6 connections. The value of the Protocol field determines the format of the rest of the Socket Connection Request. For detailed descriptions of the fields in the table, see Field Descriptions.


IPv4 connection (Protocol field value is 1 or 2)



IPv6 connection (Protocol field value is 3 or 4)



Field Descriptions

Local IPv4 address. The IPv4 address of the host at the local end of the connection.

Local IPv6 address. The IPv6 address of the host at the local end of the connection. Even though this field is defined as a character field, it must be stored in binary. It is recommended that you use the Sockets in6_addr structure.

Local port number. The port number of the local end of the connection.

Protocol. The type and IP version of connection protocol.

Possible values are:

Remote IPv4 address. The IPv4 address of the host at the remote end of the connection.

Remote IPv6 address. The IPv6 address of the host at the remote end of the connection. Even though this field is defined as a character field, it must be stored in binary. It is recommended that you use the Sockets in6_addr structure.

Remote port number. The port number of the remote end of the connection.


Format of Returned Connection Data

To retrieve the current TCP/IPv4 connection totals, use format NCND0100.

To retrieve the current TCP/IPv6 connection totals, use format NCND1100.

For detailed TCP and UDP connection status for a specific IPv4 socket connection in addition to the TCP/IPv4 connection totals, use format NCND0200.

For detailed TCP and UDP connection status for a specific IPv6 socket connection in addition to the TCP/IPv6 connection totals, use format NCND1200.


NCND0100 Format

Format NCND0100 returns information regarding the TCP/IPv4 connection totals. For detailed descriptions of the fields in the table, see Field Descriptions.



Field Descriptions

Bytes available. All of the available bytes for use in your application.

Bytes returned. The number of bytes returned to the user. This may be some but not all the bytes available.

Length of Additional Information.The length in bytes of additional information returned that is not part of format NCND0100.

Offset to Additional Information. The offset in bytes to the rest of the information if a format other than NCND0100 is requested.

TCP active opens. The number of times TCP connections have made a direct transition to the SYN-SENT state from the CLOSED state. This number is an indication of the number of times this local system opened a connection to a remote system.

TCP attempted opens that failed. The total number of times TCP connections have made direct transitions to a CLOSED state from either the SYN-SENT state or the SYN-RECEIVED state and/or to LISTEN from SYN-RECEIVED.

TCP connections currently established. The number of TCP connections for which the current state is either ESTABLISHED or CLOSE-WAIT.

TCP established and then reset. The number of times TCP connections have made a direct transition to the CLOSED state from either the ESTABLISHED state or the CLOSE-WAIT state.

TCP passive opens. The number of times TCP connections have made a direct transition to the SYN-RECEIVED state from the LISTEN state. This number is an indication of the number of times a remote system opened a connection to this system.

TCP reset segments. The number of TCP segments sent containing the RST flag.

TCP retransmitted segments. The number of TCP segments transmitted containing one or more previously transmitted octets.

TCP segments received. The total number of segments received, including those received in error. This count includes segments received on currently established connections.

TCP segments received in error. The total number of segments received in error (for example, bad TCP checksums).

TCP segments sent. The total number of segments sent, including those on current connections but excluding those containing only retransmitted octets.

UDP datagrams not delivered - application port not found. The total number of received UDP datagrams for UDP users for which there was no application at the destination port.

UDP datagrams not delivered - other datagrams in error. The number of received UDP datagrams that could not be delivered for reasons other than the lack of an application at the destination port.

UDP datagrams received. The total number of datagrams received, including those received in error. This count includes datagrams received on currently established connections.

UDP datagrams sent. The total number of UDP datagrams sent from all connections since TCP/IP was started.



NCND0200 Format

This format returns detailed information about the TCP connection status in addition to the TCP/IPv4 connection totals (format NCND0100). For detailed descriptions of the fields in the table, see Field Descriptions.



List of Socket Options

These fields repeat for each socket option.



List of Jobs/Tasks Associated with this Connection

These fields repeat for each job or task.



Field Descriptions

Associated user profile. The user profile of the job on the local system which first performed a sockets API bind() of the socket.

Note: This field does not reliably indicate the current user of a connection or socket. To see a list of the jobs or tasks currently using a connection or socket, use the List of Jobs/Tasks Associated with this Connection.

Bytes in. The total number of bytes received on the connection, including framing characters.

Bytes out. The total number of bytes transmitted on the connection, including framing characters.

Congestion window. The number of segments that are sent on the next transmission. If an acknowledgment is received, the number is increased. If an acknowledgment is not received, the number is reset to the smallest allowable number. This field is only valid for TCP connections.

Connection open type. A TCP connection can be opened in the following ways:

Connection transport layer. The transport that a connection is using:

Current retransmissions. The number of times the local system retransmitted the current segment without receiving an acknowledgment. This is sometimes referred to as the 'backoff count'. This field is only valid for TCP connections.

Current user profile. The user profile that the thread for which information is being retrieved is currently running under. This name may differ from the user portion of the job name. If this field is requested for a job, the value for the initial thread of the job will be returned.

Current window size. The current send window size in bytes. This field is only valid for TCP connections.

Entry length for list of jobs associated with connection. The entry length in bytes of each element in the list of job connections returned with this format. A value of zero is returned if the list is empty.

Entry length for list of socket options associated with connection. The entry length in bytes of each element in the list of socket options returned with this format. A value of zero is returned if the list is empty.

Format entry. Type of list format for job or task connections.

Idle time. The length of time since the last activity on this connection. The length of time is returned in milliseconds.

Incoming bytes buffered. The current number of bytes that are received and buffered by TCP. These bytes are available to be read by an application.

Incoming push number. The sequence number of the last byte of pushed data in the incoming data stream. This value is zero if no push data is in the incoming data stream. This field is only valid for TCP connections.

Incoming urgency number. The sequence number of the last byte of urgent data in the incoming data stream. This value is zero if no urgent data is in the incoming data stream. This field is only valid for TCP connections.

Incoming window number. The largest sequence number in the incoming window of this connection. Data bytes in the incoming stream having sequence numbers larger than this number are not accepted. This field is only valid for TCP connections.

Initial receive sequence number. The first sequence number received on this connection. This field is only valid for TCP connections.

Initial send sequence number. The first sequence number sent on this connection. This field is only valid for TCP connections.

IP options. Used in displaying the IP datagram options that may have been specified for a connection.

Internal job identifier. A value sent to other APIs to speed the process of locating the job on the system.

Job name. The simple job name as identified to the system.

Job number. System-assigned job or task number.

Job type. The type of the job.

Job user name. The user name identifies the user profile under which the job is started. The following special value may be returned:

Last update. The sequence number of the incoming segment used for the last window update that occurred on the connection. This field is only valid for TCP connections.

Last update acknowledged. The acknowledgment number of the incoming segment used for the last window update that occurred on the connection. This field is only valid for TCP connections.

Local IP address. The local address of this connection on this system.

Local port number. Your local system port number.

Maximum segment size. The size in bytes of the largest segment that may be transmitted on this connection. This field is only valid for TCP connections.

Maximum window size. The largest size of the send window, in bytes, during the entire time the connection has been active. This field is only valid for TCP connections.

Number of jobs associated with connection. The number of elements in the list of job connections returned with this format. A value of zero is returned if the list is empty.

Number of socket options associated with connection. The number of elements in the list of socket options returned with this format. A value of zero is returned if the list is empty.

Offset to list of jobs associated with connection. The offset in bytes to the first element in the list of job connections returned with this format. A value of zero is returned if the list is empty.

Offset to list of socket options associated with connection. The offset in bytes to the first element in the list of socket options returned with this format. A value of zero is returned if the list is empty.

Option value. The value returned for a particular socket option. Option is set if a nonzero value is returned.

Outgoing bytes buffered. The current number of bytes that an application has requested to send, but TCP has not yet sent. If TCP has sent the bytes to the remote system but has not yet received an acknowledgment, the bytes are considered 'not sent'. They are included in this count.

Outgoing push number. The sequence number of the last byte of push data in the outgoing stream. This value is zero if no push data is in the outgoing data stream. This field is only valid for TCP connections.

Outgoing urgency number. The sequence number of the last byte of urgent data in the outgoing data stream. This value is zero if no urgent data is in the outgoing data stream. This field is only valid for TCP connections.

Outgoing window number. The largest sequence number in the send window of the connection. The local TCP application cannot send data bytes with sequence numbers greater than the outgoing window number.

Protocol. Identifies the type of connection protocol.

Receive next. The next sequence number the local TCP is expecting to receive.

Remote IP address. The Internet address of the remote host. Zero is shown, if the list entry is for a UDP socket.

Remote port number. The remote host port number. Zero is shown, if the list entry is for a UDP socket.

Reserved. An ignored field.

Round-trip time. The smoothed round-trip time interval in milliseconds. This is a measure of the time required for a segment on the connection to arrive at its destination, to be processed, and to return an acknowledgment to the client. This field is only valid for TCP connections.

Round-trip variance.The variance in milliseconds from the previous round-trip time. This field is only valid for TCP connections.

Send next. The sequence number of the next byte of data that the local TCP application sends to the remote TCP application.

Send unacknowledged. The sequence number of the last segment sent that was not acknowledged. This is the smallest sequence number of the send window. This field is only valid for TCP connections.

Slow start threshold. The current values for the slow-start threshold and the congestion window are indirect indicators of the flow of data through a TCP connection. These values are used by TCP as part of a congestion control algorithm. This algorithm ensures that this system sends data at a slow rate at first. After the first data has been successfully sent, the rate in which data is sent increases. This change is made in a controlled manner that is dependent on the amount of congestion in the network. Congestion control occurs both at connection start time and when congestion is detected. The values used for the slow-start threshold and the congestion window are determined by TCP and cannot be set by the user.

Socket option. Socket options for this connection.

Socket state. The current state of the socket.

Task name. The task name as identified to the system.

TCP state. A typical connection goes through the states:

Total retransmissions. The total number of times the local system retransmitted a segment because an acknowledgment was not received. This is a cumulative count of all segments resent during the entire time the connection has been active. This field is only valid for TCP connections.

User send next. The sequence number of the next byte of data to be sent by the client application. This field is only valid for TCP connections.

User receive next. The sequence number of the next byte to be passed to the application by TCP.


NCND1100 Format

Format NCND1100 returns information regarding the TCP/IPv6 connection totals. For detailed descriptions of the fields in the table, see Field Descriptions.



Field Descriptions

Bytes available. All of the available bytes for use in your application.

Bytes returned. The number of bytes returned to the user. This may be some but not all the bytes available.

Length of Additional Information.The length in bytes of additional information returned that is not part of format NCND0100.

Offset to Additional Information. The offset in bytes to the rest of the information if a format other than NCND0100 is requested.

TCP active opens. The number of times TCP connections have made a direct transition to the SYN-SENT state from the CLOSED state. This number is an indication of the number of times this local system opened a connection to a remote system.

TCP attempted opens that failed. The total number of times TCP connections have made direct transitions to a CLOSED state from either the SYN-SENT state or the SYN-RECEIVED state and/or to LISTEN from SYN-RECEIVED.

TCP connections currently established. The number of TCP connections for which the current state is either ESTABLISHED or CLOSE-WAIT.

TCP established and then reset. The number of times TCP connections have made a direct transition to the CLOSED state from either the ESTABLISHED state or the CLOSE-WAIT state.

TCP passive opens. The number of times TCP connections have made a direct transition to the SYN-RECEIVED state from the LISTEN state. This number is an indication of the number of times a remote system opened a connection to this system.

TCP reset segments. The number of TCP segments sent containing the RST flag.

TCP retransmitted segments. The number of TCP segments transmitted containing one or more previously transmitted octets.

TCP segments received. The total number of segments received, including those received in error. This count includes segments received on currently established connections.

TCP segments received in error. The total number of segments received in error (for example, bad TCP checksums).

TCP segments sent. The total number of segments sent, including those on current connections but excluding those containing only retransmitted octets.

UDP datagrams not delivered - application port not found. The total number of received UDP datagrams for UDP users for which there was no application at the destination port.

UDP datagrams not delivered - other datagrams in error. The number of received UDP datagrams that could not be delivered for reasons other than the lack of an application at the destination port.

UDP datagrams received. The total number of datagrams received, including those received in error. This count includes datagrams received on currently established connections.

UDP datagrams sent. The total number of UDP datagrams sent from all connections since TCP/IP was started.


NCND1200 Format

This format returns detailed information about the TCP connection status in addition to the TCP/IPv6 connection totals (format NCND1100). For detailed descriptions of the fields in the table, see Field Descriptions.



List of Socket Options

These fields repeat for each socket option.



List of Jobs/Tasks Associated with this Connection

These fields repeat for each job or task.



Field Descriptions

Associated user profile. The user profile of the job on the local system which first performed a sockets API bind() of the socket.

Note: This field does not reliably indicate the current user of a connection or socket. To see a list of the jobs or tasks currently using a connection or socket, use the List of Jobs/Tasks Associated with this Connection.

Bytes in. The total number of bytes received on the connection, including framing characters.

Bytes out. The total number of bytes transmitted on the connection, including framing characters.

Congestion window. The number of segments that are sent on the next transmission. If an acknowledgment is received, the number is increased. If an acknowledgment is not received, the number is reset to the smallest allowable number. This field is only valid for TCP connections.

Connection open type. The method in which the TCP connection was opened.

Possible values are:

Connection transport layer. The transport that the connection is using.

Possible values are:

Current retransmissions. The number of times the local system retransmitted the current segment without receiving an acknowledgment. This is sometimes referred to as the 'backoff count'. This field is only valid for TCP connections.

Current user profile. The user profile that the thread for which information is being retrieved is currently running under. This name may differ from the user portion of the job name. If this field is requested for a job, the value for the initial thread of the job will be returned.

Current window size. The current send window size in bytes. This field is only valid for TCP connections.

Entry length for list of jobs associated with connection. The entry length in bytes of each element in the list of job connections returned with this format. A value of zero is returned if the list is empty.

Entry length for list of socket options associated with connection. The entry length in bytes of each element in the list of socket options returned with this format. A value of zero is returned if the list is empty.

Entry type. Specifies whether this entry is a job or a task.

Possible values are:

Idle time. The length of time since the last activity on this connection. The length of time is returned in milliseconds.

Incoming bytes buffered. The current number of bytes that are received and buffered by TCP. These bytes are available to be read by an application.

Incoming push number. The sequence number of the last byte of pushed data in the incoming data stream. This value is zero if no push data is in the incoming data stream. This field is only valid for TCP connections.

Incoming urgency number. The sequence number of the last byte of urgent data in the incoming data stream. This value is zero if no urgent data is in the incoming data stream. This field is only valid for TCP connections.

Incoming window number. The largest sequence number in the incoming window of this connection. Data bytes in the incoming stream having sequence numbers larger than this number are not accepted. This field is only valid for TCP connections.

Initial receive sequence number. The first sequence number received on this connection. This field is only valid for TCP connections.

Initial send sequence number. The first sequence number sent on this connection. This field is only valid for TCP connections.

Internal job identifier. A value sent to other APIs to speed the process of locating the job on the system.

Job name. The simple job name as identified to the system.

Job number. System-assigned job or task number.

Job type. The type of the job.

Job user name. The user name identifies the user profile under which the job is started.

The following special value may be returned:

Last update. The sequence number of the incoming segment used for the last window update that occurred on the connection. This field is only valid for TCP connections.

Last update acknowledged. The acknowledgment number of the incoming segment used for the last window update that occurred on the connection. This field is only valid for TCP connections.

Local IPv6 address. The local system Internet address, in IPv6 address format, of the connection. Even though this field is defined as a character field, a binary IPv6 address is returned in it.

Local port number. The port number of the local end of the connection.

Maximum segment size. The size in bytes of the largest segment that may be transmitted on this connection. This field is only valid for TCP connections.

Maximum window size. The largest size of the send window, in bytes, during the entire time the connection has been active. This field is only valid for TCP connections.

Number of jobs associated with connection. The number of elements in the list of job connections returned with this format. A value of zero is returned if the list is empty.

Number of socket options associated with connection. The number of elements in the list of socket options returned with this format. A value of zero is returned if the list is empty.

Offset to list of jobs associated with connection. The offset in bytes to the first element in the list of job connections returned with this format. A value of zero is returned if the list is empty.

Offset to list of socket options associated with connection. The offset in bytes to the first element in the list of socket options returned with this format. A value of zero is returned if the list is empty.

Option value. The value returned for a particular socket option. The socket option is set if a nonzero value is returned.

Outgoing bytes buffered. The current number of bytes that an application has requested to send, but TCP has not yet sent. If TCP has sent the bytes to the remote system but has not yet received an acknowledgment, the bytes are considered 'not sent'. They are included in this count.

Outgoing push number. The sequence number of the last byte of push data in the outgoing stream. This value is zero if no push data is in the outgoing data stream. This field is only valid for TCP connections.

Outgoing urgency number. The sequence number of the last byte of urgent data in the outgoing data stream. This value is zero if no urgent data is in the outgoing data stream. This field is only valid for TCP connections.

Outgoing window number. The largest sequence number in the send window of the connection. The local TCP application cannot send data bytes with sequence numbers greater than the outgoing window number.

Protocol. Identifies the type of connection protocol.

Receive next. The next sequence number that TCP is expecting to receive.

Remote IPv6 address. The local system Internet address, in IPv6 address format, of the connection. Even though this field is defined as a character field, a binary IPv6 address is returned in it.

The following special value may be returned:

Remote port number. The port number of the remote end of the connection.

The following special value may be returned:

Reserved. An ignored field.

Round-trip time. The smoothed round-trip time interval in milliseconds. This is a measure of the time required for a segment on the connection to arrive at its destination, to be processed, and to return an acknowledgment to the client. This field is only valid for TCP connections.

Round-trip variance.The variance in milliseconds from the previous round-trip time. This field is only valid for TCP connections.

Send next. The sequence number of the next byte of data that the local TCP application sends to the remote TCP application.

Send unacknowledged. The sequence number of the last segment sent that was not acknowledged. This is the smallest sequence number of the send window. This field is only valid for TCP connections.

Slow start threshold. The current values for the slow-start threshold and the congestion window are indirect indicators of the flow of data through a TCP connection. These values are used by TCP as part of a congestion control algorithm. This algorithm ensures that this system sends data at a slow rate at first. After the first data has been successfully sent, the rate in which data is sent increases. This change is made in a controlled manner that is dependent on the amount of congestion in the network. Congestion control occurs both at connection start time and when congestion is detected. The values used for the slow-start threshold and the congestion window are determined by TCP and cannot be set by the user.

Socket option. Socket options for this connection.

Socket state. The current state of the socket.

Possible values are:

Task name. The task name as identified to the system.

TCP state. A typical connection goes through the states:

Total retransmissions. The total number of times the local system retransmitted a segment because an acknowledgment was not received. This is a cumulative count of all segments resent during the entire time the connection has been active. This field is only valid for TCP connections.

User send next. The sequence number of the next byte of data to be sent by the client application. This field is only valid for TCP connections.

User receive next. The sequence number of the next byte to be passed to the application by TCP.


Error Messages




API introduced: V5R1