EasyManua.ls Logo

Intermec Antares 2420 - Page 168

Intermec Antares 2420
480 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
TRAKKER Antares 2420 and 2425 Hand-Held Terminal User’s Manual
Co de 39
Nugget
4-34
CLIENT.CPP Sample Application for a TCP/IP Direct Connect Network (continued)
// attempt to connect to the server
error = connect(connection, (const SOCKADDR *)&serverAddress,
sizeof(serverAddress));
if (error != 0)
ErrorMessage("connect", WSAGetLastError());
// check the local name for the socket
SOCKADDR_IN localName;
memset(&localName, 0, sizeof(localName));
int localNameLength = sizeof(localName);
error = getsockname(connection, (LPSOCKADDR)&localName, &localNameLength);
// run the user-interface
char sz[1024];
char rz[1024];
BOOL bConnectionAlive = TRUE;
printf("> ");
int Scount, Rcount;
int cbRecv, cbSend;
Scount = Rcount = 0;
int cbLen, rcLen;
unsigned char *psend = (unsigned char *)sz;
// continue while not EOF on the console and the connection is alive
while (bConnectionAlive)
{
// send the string entered by the user
printf("Enter Command:\n");
printf("> ");
gets(sz);
if(sz[0] != 'q')
{
cbLen = strlen(sz);
cbSend = send(connection, (const char *)psend, cbLen, 0);
if (cbSend < 0)
{
Scount++;
printf("send failed %d\n", Scount);
bConnectionAlive = FALSE;
ErrorMessage("send", WSAGetLastError());
}
Sleep(2000);
// receive the converted string from the server
memset(&rz, 0, sizeof(rz));
rcLen = sizeof(rz);
cbRecv = recv(connection, rz, rcLen, 0);
if (cbRecv < 0)
{

Table of Contents

Other manuals for Intermec Antares 2420

Related product manuals