Intermec 2430 User Guide

Page of 374
Chapter 2—Configuring and Managing the Terminals 
26 
Trakker Antares 2400 Family System Manual 
To use the sample utility CLIENT.CPP 
Make sure the TFTP server is running on the host and the RF or 
Ethernet terminal is communicating with the host. 
In the hosts file on the host, add the terminal IP addresses and the target 
name, NCM. For example, to send files or data to the terminal with an 
IP address of 192.9.200.130, add this line to the hosts file: 
 192.9.200.130 
ncm 
Start the CLIENT.EXE application on the host. 
When the “Enter Command” prompt appears on the host, enter the 
two-character TMF code, CS (Configuration Set request) followed by 
the reader or configuration command. 
For example, to send the application INVENTRY.BIN from drive C on 
the host to drive C on the terminal, enter this command: 
 CS.%R,c:inventry.bin,c:inventry.bin 
CLIENT.CPP Sample Application for a TCP/IP Direct Connect Network 
#include <windows.h> 
#include <stdio.h> 
#include "Utils.h" 
// our application uses a fixed port number 
const unsigned short SERVER_PORT = 6000; 
const unsigned short CLIENT_PORT = 6001; 
// we will default to the local host machine 
// unless argv[1] has a hostname 
const char SERVER_HOSTNAME[] = "ncm"; 
int main(int argc, char *argv[]) 
// turn on the socket library for this process 
    WSADATA wsad; 
    int error = WSAStartup(MAKEWORD(1,1), &wsad); 
    if (error != 0) 
        ErrorMessage("WSAStartup", WSAGetLastError()); 
// create an unitialized connection-oriented socket  
    SOCKET connection; 
    connection = socket(PF_INET, SOCK_DGRAM, 0); 
    if (connection == INVALID_SOCKET) 
        ErrorMessage("socket", WSAGetLastError()); 
// lookup the IP address of the requested host 
    HOSTENT *phostent = gethostbyname(argc == 2 ? argv[1] : SERVER_HOSTNAME); 
    if (phostent == 0) 
        ErrorMessage("gethostbyname", WSAGetLastError()); 
// define a SOCKADDR to contain the IP address of the  
// server and the port number of our application 
    SOCKADDR_IN serverAddress; 
    memset(&serverAddress, 0, sizeof(serverAddress)); 
    serverAddress.sin_family = PF_INET;