tcpstr1.cpp

00001 #include <cc++/socket.h>
00002 #include <iostream>
00003 #include <cstdlib>
00004 
00005 #ifdef  CCXX_NAMESPACES
00006 using namespace std;
00007 using namespace ost;
00008 #endif
00009 
00010 class ThreadOut: public Thread
00011 {
00012 public:
00013         ThreadOut()
00014         {
00015                 start();
00016         }
00017         void run()
00018         {
00019                 TCPStream tcp("127.0.0.1:9000");
00020                 tcp << "pippo" << endl;
00021                 tcp.disconnect();
00022         }
00023 };
00024 
00025 int main(int argc, char *argv[])
00026 {
00027         char line[200];
00028 
00029         InetAddress addr = "127.0.0.1";
00030         TCPSocket *sock = new TCPSocket(addr, 9000);
00031         // write some output automatically
00032         ThreadOut thread;
00033         while (1){
00034                 if (sock->isPendingConnection()){
00035                         TCPStream tcp(*sock);
00036                         tcp.getline(line, 200);
00037                         cout << line << endl;
00038                         tcp.disconnect();
00039                         return 0;
00040                 }
00041         }
00042         return 0;
00043 }
00044 

Generated on Tue Jan 9 16:38:58 2007 for GNU CommonC++ by  doxygen 1.5.1