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());
}
Содержание Trakker Antares 2460
Страница 1: ...Trakker Antares 246X Stationary Terminal User s Manual...
Страница 4: ...blank page...
Страница 19: ...Introducing the 246X Stationary Terminal 1...
Страница 20: ...blank page...
Страница 29: ...Installing the Terminal 2...
Страница 30: ...blank page...
Страница 47: ...Configuring the Terminal 3...
Страница 48: ...blank page...
Страница 58: ...blank page...
Страница 59: ...Operating the Terminal in a Network 4...
Страница 60: ...blank page...
Страница 88: ...blank page...
Страница 89: ...Programming the Terminal 5...
Страница 90: ...blank page...
Страница 107: ...Troubleshooting 6...
Страница 108: ...blank page...
Страница 121: ...Reader Command Reference 7...
Страница 122: ...blank page...
Страница 149: ...Configuration Command Reference 8...
Страница 150: ...blank page blank page...
Страница 242: ...blank page blank page...
Страница 243: ...Specifications A...
Страница 244: ...blank page blank page...
Страница 257: ...Full ASCII Charts B...
Страница 258: ...blank page blank page...
Страница 267: ...Using the Default Applications C...
Страница 268: ...blank page blank page...
Страница 279: ...Index I...
Страница 280: ...blank page...
Страница 290: ...body text 4...