Co de 39
Nugget
Operating the Terminal in a Network
4-33
4
CLIENT.CPP Sample Application for a TCP/IP Direct Connect Network
#include <windows.h>
#include <stdio.h>
#include "d:\class\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;
serverAddress.sin_port = htons(SERVER_PORT);
memcpy(&serverAddress.sin_addr, phostent->h_addr_list[0], phostent->h_length);
// Bind a well known port of 6000 to the socket
SOCKADDR_IN clientAddress;
memset(&clientAddress, 0, sizeof(clientAddress));
clientAddress.sin_family = PF_INET;
clientAddress.sin_port = htons(CLIENT_PORT);
clientAddress.sin_addr.s_addr = htonl(INADDR_ANY);
if(!(bind(connection, (LPSOCKADDR)&clientAddress, sizeof(clientAddress))
==0))
{
ErrorMessage("bind", WSAGetLastError());
}
Summary of Contents for Trakker Antares 2420
Page 1: ...TRAKKERAntares 2420and2425 Hand HeldTerminal P N 064024 006 User s Manual...
Page 15: ...nuggetf code39 Contents xv Glossary Index G I...
Page 16: ...xvi...
Page 24: ...xxiv...
Page 25: ...nuggetf code39 Getting Started 1...
Page 26: ...1 2...
Page 60: ...1 36...
Page 61: ...Learning How to Use the Terminal 2...
Page 62: ...2 2...
Page 103: ...Co de 39 Nugget Configuring the Terminal 3...
Page 104: ...Co de 39 Nugget 3 2...
Page 134: ...3 32...
Page 135: ...Operating the Terminal in a Network 4...
Page 136: ...4 2...
Page 173: ...Using Custom Applications 5...
Page 174: ...5 2...
Page 193: ...Troubleshooting 6...
Page 194: ...6 2...
Page 219: ...Running Diagnostics 7...
Page 220: ...7 2...
Page 243: ...Reader Command Reference 8...
Page 244: ...8 2...
Page 268: ...8 26...
Page 269: ...Configuration Command Reference 9...
Page 270: ...9 2...
Page 389: ...Terminal Specifications A...
Page 390: ...A 2...
Page 404: ...A 16...
Page 405: ...Full ASCII Charts B...
Page 406: ...B 2...
Page 415: ...International Character Support C...
Page 416: ...C 2...
Page 427: ...Using the Default Applications D...
Page 428: ...D 2...
Page 438: ...D 12...
Page 439: ...Glossary G...
Page 440: ...G 2...
Page 463: ...Index I...
Page 464: ...I 2...
Page 480: ...I 18...