This chapter contains a description of all NetX Duo Telnet Services (listed below) in alphabetic order.
In the “Return Values” section in the following API descriptions, values in BOLD are not affected by the NX_DISABLE_ERROR_CHECKING define that is used to disable API error checking, while non-bold values are completely disabled.
Connect a Telnet Client with IPv4 address
UINT nx_telnet_client_connect(
NX_TELNET_CLIENT *client_ptr,
ULONG server_ip,
UINT server_port,
ULONG wait_option);
This service attempts to connect the previously created Telnet Client instance to the Server at the specified IP and port using an IPv4 address for the Telnet Server. This service actually inserts the ULONG server IP address in an NXD_ADDRESS control block and sets the IP version to 4 before calling the nxd_telnet_client_connect service described below.
Threads
/* Connect the Telnet Client instance "my_client" to the Server at
IP address 1.2.3.4 and port 23. */
status = nx_telnet_client_connect(&my_client, IP_ADDRESS(1,2,3,4), 23, 100);
/* If status is NX_SUCCESS the Telnet Client instance was successfully
connected to the Telnet Server. */
Connect a Telnet Client with IPv6 or IPv4 address
UINT nxd_telnet_client_connect(
NX_TELNET_CLIENT *client_ptr,
NXD_ADDRESS *server_ip_address,
UINT server_port,
ULONG wait_option);
This service attempts to connect the previously created Telnet Client instance to the Server at the specified IP and port using the Telnet Server’s IPv6 address. This service can take an IPv4 or an IPv6 address but must be contained in the NXD_ADDRESS variable server_ip_address.
Threads
/* Connect the Telnet Client instance "my_client" to the Server at
IPv6 address 20010db1:0:f101::101 and port 23. */
status = nxd_telnet_client_connect(&my_client, &server_ip_address, 23, 100);
/* If status is NX_SUCCESS the Telnet Client instance was successfully
connected to the Telnet Server. */
Create a Telnet Client
UINT nx_telnet_client_create(
NX_TELNET_CLIENT *client_ptr,
CHAR *client_name, NX_IP *ip_ptr,
ULONG window_size);
This service creates a Telnet Client instance.
Initialization, Threads
/* Create the Telnet Client instance "my_client" on the IP instance "ip_0". */
status = nx_telnet_client_create(&my_client, "My Telnet Client", &ip_0, 2048);
/* If status is NX_SUCCESS the Telnet Client instance was successfully
created. */
Delete a Telnet Client
UINT nx_telnet_client_delete(NX_TELNET_CLIENT *client_ptr);
This service deletes a previously created Telnet Client instance.
Threads
/* Delete the Telnet Client instance "my_client". */
status = nx_telnet_client_delete(&my_client);
/* If status is NX_SUCCESS the Telnet Client instance was successfully
deleted. */
Disconnect a Telnet Client
UINT nx_telnet_client_disconnect(
NX_TELNET_CLIENT *client_ptr,
ULONG wait_option);
This service disconnects a previously connected Telnet Client instance.
Threads
/* Disconnect the Telnet Client instance "my_client". */
status = nx_telnet_client_disconnect(&my_client, 100);
/* If status is NX_SUCCESS the Telnet Client instance was successfully
disconnected. */
Receive packet via Telnet Client
UINT nx_telnet_client_packet_receive(
NX_TELNET_CLIENT *client_ptr,
NX_PACKET **packet_ptr,
ULONG wait_option);
This service receives a packet from the previously connected Telnet Client instance.
Threads
/* Receive a packet from the Telnet Client instance "my_client". */
status = nx_telnet_client_packet_receive(&my_client, &my_packet, 100);
/* If status is NX_SUCCESS the "my_packet" pointer contains data received from
the Telnet Client connection. */
Send packet via Telnet Client
UINT nx_telnet_client_packet_send(
NX_TELNET_CLIENT *client_ptr,
NX_PACKET *packet_ptr,
ULONG wait_option);
This service sends a packet through the previously connected Telnet Client instance.
Threads
/* Send a packet via the Telnet Client instance "my_client". */
status = nx_telnet_client_packet_send(&my_client, my_packet, 100);
/* If status is NX_SUCCESS the packet was successfully sent. */
Create a Telnet Server
UINT nx_telnet_server_create(
NX_TELNET_SERVER *server_ptr,
CHAR *server_name,
NX_IP *ip_ptr,
VOID *stack_ptr,
ULONG stack_size,
void (*new_connection)(
struct NX_TELNET_SERVER_STRUCT*telnet_server_ptr,
UINT logical_connection),
void (*receive_data)(
struct NX_TELNET_SERVER_STRUCT *telnet_server_ptr,
UINT logical_connection,
NX_PACKET *packet_ptr),
void (*connection_end)(
struct NX_TELNET_SERVER_STRUCT *telnet_server_ptr,
UINT logical_connection));
This service creates a Telnet Server instance on the specified IP instance.
Initialization, Threads
/* Create a Telnet Server instance "my_server". */
status = nx_telnet_server_create(&my_server, "Telnet Server", &ip_0,
pointer, 2048, telnet_new_connection,
telnet_receive_data, telnet_connection_end);
/* If status is NX_SUCCESS the Telnet Server was successfully created. */
Delete a Telnet Server
UINT nx_telnet_server_delete(NX_TELNET_SERVER *server_ptr);
This service deletes a previously created Telnet Server instance.
Threads
/* Delete the Telnet Server instance "my_server". */
status = nx_telnet_server_delete(&my_server);
/* If status is NX_SUCCESS the Telnet Server was successfully deleted. */
Disconnect a Telnet Client
UINT nx_telnet_server_disconnect(
NX_TELNET_SERVER *server_ptr,
UINT logical_connection);
This service disconnects a previously connected Client on this Telnet Server instance. This routine is typically called from the application’s receive data callback function in response to a condition detected in the data received.
Threads
/* Disconnect the Telnet Client associated with logical connection 2 on
the Telnet Server instance "my_server". */
status = nx_telnet_server_disconnect(&my_server, 2);
/* If status is NX_SUCCESS the Client on logical connection 2 was
disconnected. */
Return number of currently open connections
UINT nx_telnet_server_get_open_connection_count(
NX_TELNET_SERVER *server_ptr,
UINT *connection_count);
This service returns the number of currently connected Telnet Clients.
Threads
/* Get the number of Telnet Clients connected to the Server. */
status = nx_telnet_server_get_open_connection_count(&my_server, &conn_count);
/* If status is NX_SUCCESS the conn_count holds the number of open connections. */
Send packet through Client connection
UINT nx_telnet_server_packet_send(
NX_TELNET_SERVER *server_ptr,
UINT logical_connection,
NX_PACKET *packet_ptr,
ULONG wait_option);
This service sends a packet to the Client connection on this Telnet Server instance. This routine is typically called from the application’s receive data callback function in response to a condition detected in the data received.
Threads
/* Send a packet to the Telnet Client associated with logical connection 2 on
the Telnet Server instance "my_server". */
status = nx_telnet_server_packet_send(&my_server, 2, my_packet, 100);
/* If status is NX_SUCCESS the packet was sent to the Client on logical
connection 2. */
Set previously created packet pool as Telnet Server pool
UINT nx_telnet_server_packet_pool_set(
NX_TELNET_SERVER *server_ptr,
NX_PACKET_POOL *packet_pool_ptr);
This service sets a previously created packet pool as the Telnet Server packet pool if NX_TELNET_SERVER_USER_CREATE_PACKET_POOL is defined. It also requires that NX_TELNET_SERVER_OPTION_DISABLE not be defined such that the Telnet Server needs a packet pool to transmit Telnet options to Telnet clients.
This permits applications to create the packet pool in different memory e.g. no cache memory, than the Telnet Server stack. Note that if this function does not check if the Telnet Server packet pool is already set. If it is called on a non null Telnet Server packet pool pointer, it will overwrite it and replace the existing packet pool with packet pool pointed to by the input pointer.
Init, Threads
status = nx_packet_pool_create(&telnet_server_packet_pool,
"Telnet Server Packet Pool",
telnet_server_pool_area, 600*10);
/* Set the packet pool as the Telnet Server packet pool. */
status = nx_telnet_server_packet_pool_set(&my_server, &telnet_server_packet_pool);
/* If status is NX_SUCCESS the packet pool is set as Telnet Server pool. */
Start a Telnet Server
UINT nx_telnet_server_start(NX_TELNET_SERVER *server_ptr);
This service starts a previously created Telnet Server instance.
Initialization, Threads
/* Start the Telnet Server instance "my_server". */
status = nx_telnet_server_start(&my_server);
/* If status is NX_SUCCESS the Server was started. */
Stop a Telnet Server
UINT nx_telnet_server_stop(NX_TELNET_SERVER *server_ptr);
This service stops a previously created and started Telnet Server instance.
Threads
/* Stop the Telnet Server instance "my_server". */
status = nx_telnet_server_stop(&my_server);
/* If status is NX_SUCCESS the Server was stopped. */