Logo
~Sockets~
~Examples~
~Contact~


OrderSocket Class Reference

List of all members.


Public Member Functions

 OrderSocket (ISocketHandler &h)
Socket * Create ()
void OnAccept ()
void OnLine (const std::string &line)
void OnDelete ()
void OnResolved (int id, ipaddr_t a, port_t port)
void OnResolved (int id, const std::string &name, port_t port)
void OnDetached ()

Detailed Description

Definition at line 109 of file sockets_test.cpp.


Constructor & Destructor Documentation

OrderSocket::OrderSocket ( ISocketHandler &  h  )  [inline]

Definition at line 112 of file sockets_test.cpp.

Referenced by Create().

00112                                        : TcpSocket(h) {
00113                 SetLineProtocol();
00114         }


Member Function Documentation

Socket* OrderSocket::Create (  )  [inline]

Definition at line 115 of file sockets_test.cpp.

References OrderSocket().

00115                          {
00116                 Handler().LogError(this, "Create", 0, "OrderSocket", LOG_LEVEL_INFO);
00117                 return new OrderSocket(Handler());
00118         }

void OrderSocket::OnAccept (  )  [inline]

Definition at line 119 of file sockets_test.cpp.

00119                         {
00120                 Send("Cmd (get,quit,list,stop,detach,count,resolve <name>)>");
00121         }

void OrderSocket::OnLine ( const std::string &  line  )  [inline]

Definition at line 122 of file sockets_test.cpp.

00122                                            {
00123                 Parse pa(line);
00124                 std::string cmd = pa.getword();
00125                 std::string arg = pa.getrest();
00126                 if (cmd == "get")
00127                 {
00128                         HttpGetSocket *p = new hSocket(Handler(), arg, "tmpfile.html");
00129                         p -> SetHttpVersion("HTTP/1.1");
00130                         p -> AddResponseHeader("Connection", "keep-alive");
00131                         p -> SetDeleteByHandler();
00132                         Handler().Add( p );
00133                         Send("Reading url '" + arg + "'\n");
00134                 }
00135                 else
00136                 if (cmd == "quit")
00137                 {
00138                         Send("Goodbye!\n");
00139                         SetCloseAndDelete();
00140                 }
00141                 else
00142                 if (cmd == "list")
00143                 {
00144                         static_cast<MyHandler&>(Handler()).List( this );
00145                 }
00146                 else
00147                 if (cmd == "stop")
00148                 {
00149                         static_cast<MyHandler&>(Handler()).SetQuit();
00150                 }
00151                 else
00152                 if (cmd == "resolve")
00153                 {
00154                         //Resolve( arg );
00155                         ipaddr_t a;
00156                         if (Utility::u2ip(arg, a))
00157                         {
00158                                 std::string tmp;
00159                                 Utility::l2ip(a, tmp);
00160                                 Send("Resolved: " + tmp + "\n");
00161                         }
00162                         else
00163                         {
00164                                 Send("Resolve failed: " + arg + "\n");
00165                         }
00166                 }
00167                 else
00168 /*
00169                 if (cmd == "reverse")
00170                 {
00171                         ipaddr_t a;
00172                         Utility::u2ip(arg, a); // ip -> ipaddr_t
00173                         int id = Socket::Resolve(a, 0);
00174                         Send("Resolve id = " + Utility::l2string(id) + "\n");
00175                 }
00176                 else
00177 */
00178                 if (cmd == "detach")
00179                 {
00180                         if (!Detach())
00181                         {
00182                                 Send("Detach() call failed\n");
00183                         }
00184                         else
00185                         {
00186                                 Send("Ok.\n");
00187                         }
00188                 }
00189                 else
00190                 if (cmd == "count")
00191                 {
00192                         Send("Socket count: " + Utility::l2string( (long)Handler().GetCount()) + "\n");
00193                 }
00194                 else
00195                 {
00196                         Send("Huh?\n");
00197                 }
00198                 Send("Cmd>");
00199         }

void OrderSocket::OnDelete (  )  [inline]

Definition at line 200 of file sockets_test.cpp.

00200                         {
00201                 printf("OrderSocket::OnDelete()\n");
00202         }

void OrderSocket::OnResolved ( int  id,
ipaddr_t  a,
port_t  port 
) [inline]

Definition at line 203 of file sockets_test.cpp.

00204         {
00205         }

void OrderSocket::OnResolved ( int  id,
const std::string &  name,
port_t  port 
) [inline]

Definition at line 206 of file sockets_test.cpp.

00207         {
00208                 Send("Resolve id " + Utility::l2string(id) + " = " + name + "\n");
00209         }

void OrderSocket::OnDetached (  )  [inline]

Definition at line 224 of file sockets_test.cpp.

00224                           {
00225                 Send("\nDetached.\nCmd>");
00226         }


The documentation for this class was generated from the following file:
Page, code, and content Copyright (C) 2007 by Anders Hedström
Generated for C++ Sockets by  doxygen 1.4.4