
388 12. Network Programming
12.11.1 Chat Client
Let’s examine the client program rst. e main.cpp le begins by including some nec-
essary header les, including our net.h le. Variables and buers are declared next (List-
ing 12.12(a)).
// Programming 2D Games
// Copyright (c) 2011 by:
// Charles Kelly
// Chat Client v1.0
#include <iostream>
#include <conio.h>
#include "net.h"
using namespace std;
int main()
{
const int BUFSIZE = 256;
int port = 48161;
int newPort = 0;
int protocol; // TCP or UDP
char remoteIP[BUFSIZE]; // Remote IP address or domain name
char localIP[16]; // Local IP address as dotted quad; nnn.nnn.
// nnn.nnn
char netbuf[BUFSIZE];