TRAKKER Antares 246X Stationary Terminal User’s Manual
nugget
39
4-24
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;
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 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...