Home  +  Forums  +  C++ and Sockets  +  C++ and SQL: MySQL, sqlite, ODBC  +  Miscellaneous Projects
Logo
~Sockets~
~New~
~Examples~
~Contact~

C++ Socket library tutorial

Using the StatusSocket as a Server

Prev   |   Menu   |   Next

Server implementation

This is the server for the StatusSocket. It works exactly as the earlier server example, it only Bind()'s to another port.

statusserver.cpp
#include <SocketHandler.h>
#include <ListenSocket.h>

#include "StatusSocket.h"


static	bool quit = false;

int main()
{
	SocketHandler h;
	ListenSocket<StatusSocket> l(h);

	if (l.Bind(9002))
	{
		exit(-1);
	}
	Utility::ResolveLocal(); // resolve local hostname
	h.Add(&l);
	h.Select(1,0);
	while (!quit)
	{
		h.Select(1,0);
	}
}



Prev   |   Menu   |   Next

Valid HTML 4.01!

Validate
Page, code, and content Copyright (C) 2021 by Anders Hedström