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                 start();
00015         }
00016         void run() {
00017                 TCPStream tcp("127.0.0.1:9000");
00018                 tcp << "pippo" << endl;
00019                 tcp.disconnect();
00020         }
00021 };
00022 
00023 int main(int argc, char *argv[])
00024 {
00025         char line[200];
00026 
00027         InetAddress addr = "127.0.0.1";
00028         TCPSocket *sock = new TCPSocket(addr, 9000);
00029         // write some output automatically
00030         ThreadOut thread;
00031         while (1){
00032                 if (sock->isPendingConnection()){
00033                         TCPStream tcp(*sock);
00034                         tcp.getline(line, 200);
00035                         cout << line << endl;
00036                         tcp.disconnect();
00037                         return 0;
00038                 }
00039         }
00040         return 0;
00041 }
00042 

Generated on Fri Feb 23 09:55:13 2007 for GNU CommonC++ by  doxygen 1.5.1