Logo
~Sockets~
~Examples~
~Contact~


sockets_test.cpp File Reference

#include <StdoutLog.h>
#include <SocketHandler.h>
#include <TcpSocket.h>
#include <ListenSocket.h>
#include <Utility.h>
#include <Parse.h>
#include <HttpGetSocket.h>
#include <PoolSocket.h>
#include <Socket.h>
#include <HttpDebugSocket.h>
#include <ResolvServer.h>

Include dependency graph for sockets_test.cpp:

Go to the source code of this file.


Classes

class  MyHandler
class  MySocket
class  hSocket
class  OrderSocket
class  TestSocket

Functions

int main ()

Function Documentation

int main (  ) 

Definition at line 257 of file sockets_test.cpp.

References MyHandler::Quit().

00258 {
00259         StdoutLog log;
00260         MyHandler h(&log);
00261 
00262         h.EnableResolver(9999);
00263 //      Utility::ResolveLocal();
00264         printf(" *** My hostname: %s\n", Utility::GetLocalHostname().c_str());
00265         printf(" *** My local IP: %s\n", Utility::GetLocalAddress().c_str());
00266 
00267         // socks4 options
00268 /*
00269         h.SetSocks4Host("127.0.0.1");
00270         h.SetSocks4Port(1080);
00271         h.SetSocks4Userid("www.alhem.net");
00272         h.SetSocks4TryDirect( true );
00273         printf("Socks4Host: %x\n", h.GetSocks4Host());
00274 */
00275 
00276         // first server
00277         ListenSocket<MySocket> l1(h);
00278         if (l1.Bind(1024))
00279         {
00280                 printf("Bind 1024 failed\n");
00281                 exit(-1);
00282         }
00283         h.Add(&l1);
00284 
00285         // second server
00286         ListenSocket<MySocket> l2(h);
00287         if (l2.Bind(1025))
00288         {
00289                 printf("Bind 1025 failed\n");
00290                 exit(-1);
00291         }
00292         h.Add(&l2);
00293 
00294         // line server
00295         ListenSocket<OrderSocket> l3(h);
00296         if (l3.Bind(1026))
00297         {
00298                 printf("Bind 1026 failed\n");
00299                 exit(-1);
00300         }
00301         h.Add(&l3);
00302 
00303         // http debug
00304         ListenSocket<HttpDebugSocket> l4(h);
00305         if (l4.Bind(8080))
00306         {
00307                 printf("Bind 8080 failed\n");
00308                 exit(-1);
00309         }
00310         h.Add(&l4);
00311 
00312         // wait for resolver to really start
00313         printf("Waiting for resolver ...");
00314         while (!h.ResolverReady())
00315                 ;
00316         printf(" resolver ready!\n");
00317 
00318         TestSocket ts(h);
00319 printf(">>> TestSocket.Open\n");
00320         ts.Open("localhost", 1026);
00321 printf(">>> Adding TestSocket\n");
00322         h.Add(&ts);
00323 
00324 printf(">>> mainloop\n");
00325         h.Select(0,0);
00326         while (!h.Quit())
00327         {
00328                 h.Select(1,0);
00329                 h.CheckSanity();
00330         }
00331 
00332         return 0;
00333 }

Page, code, and content Copyright (C) 2007 by Anders Hedström
Generated for C++ Sockets by  doxygen 1.4.4