nugget
39
Operating the Terminal in a Network
4-25
4
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)
{
+;
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)
{
Summary of Contents for Trakker Antares 2460
Page 1: ...Trakker Antares 246X Stationary Terminal User s Manual...
Page 4: ...blank page...
Page 19: ...Introducing the 246X Stationary Terminal 1...
Page 20: ...blank page...
Page 29: ...Installing the Terminal 2...
Page 30: ...blank page...
Page 47: ...Configuring the Terminal 3...
Page 48: ...blank page...
Page 58: ...blank page...
Page 59: ...Operating the Terminal in a Network 4...
Page 60: ...blank page...
Page 88: ...blank page...
Page 89: ...Programming the Terminal 5...
Page 90: ...blank page...
Page 107: ...Troubleshooting 6...
Page 108: ...blank page...
Page 121: ...Reader Command Reference 7...
Page 122: ...blank page...
Page 149: ...Configuration Command Reference 8...
Page 150: ...blank page blank page...
Page 242: ...blank page blank page...
Page 243: ...Specifications A...
Page 244: ...blank page blank page...
Page 257: ...Full ASCII Charts B...
Page 258: ...blank page blank page...
Page 267: ...Using the Default Applications C...
Page 268: ...blank page blank page...
Page 279: ...Index I...
Page 280: ...blank page...
Page 290: ...body text 4...