EasyManua.ls Logo

Intermec Antares 2420 - Page 169

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...
Co de 39
Nugget
Operating the Terminal in a Network
4-35
4
CLIENT.CPP Sample Application for a TCP/IP Direct Connect Network (continued)
Rcount++;
printf("receive failed %d\n", Rcount);
ErrorMessage("receive", WSAGetLastError());
bConnectionAlive = FALSE;
}
// printf the converted string
printf("response:%s\n",rz);
printf("\n> ");
Sleep(1000);
}
else
bConnectionAlive = FALSE;
}
// release the resources held by the socket
error = closesocket(connection);
if (error != 0)
ErrorMessage("closesocket", WSAGetLastError());
// release the resources held by the socket library
error = WSACleanup();
if (error != 0)
ErrorMessage("WSACleanup", WSAGetLastError());
return 0;
}
UTILS.H Utility (Used by CLIENT.CPP)
#include <windows.h>
inline void ErrorMessage(LPCTSTR szFn, DWORD dwError = GetLastError())
{
TCHAR szTitle[1024];
TCHAR szPrompt[1024];
BOOL bRet = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
0, dwError,
0,
szPrompt,
sizeof(szPrompt),
0);
if (!bRet)
lstrcpy(szPrompt, __TEXT("Unknown Error"));
wsprintf(szTitle, __TEXT("%s failed with error code (0x%x)!"), szFn, dwError);
int id = MessageBox(HWND_DESKTOP, szPrompt, szTitle,
MB_ABORTRETRYIGNORE|MB_SETFOREGROUND);
if (id != IDIGNORE)
ExitProcess(0);
}

Table of Contents

Other manuals for Intermec Antares 2420

Related product manuals