00001 #ifdef HAVE_CONFIG_H 00002 # include <simgear_config.h> 00003 #endif 00004 00005 #include <simgear/compiler.h> 00006 00007 #ifdef _WIN32 00008 #include <windows.h> 00009 #define sleep(x) Sleep(x*1000) 00010 #else 00011 #include <unistd.h> 00012 #endif 00013 #include <iostream> 00014 00015 #include "sg_socket.hxx" 00016 #include "lowlevel.hxx" 00017 00018 static const int sgEndianTest = 1; 00019 #define sgIsLittleEndian (*((char *) &sgEndianTest ) != 0) 00020 #define sgIsBigEndian (*((char *) &sgEndianTest ) == 0) 00021 00022 using std::cout; 00023 using std::endl; 00024 00025 00026 int main() { 00027 00028 if ( sgIsLittleEndian ) { 00029 cout << "this machine is little endian\n"; 00030 } 00031 00032 if ( sgIsBigEndian ) { 00033 cout << "this machine is big endian\n"; 00034 } 00035 00036 cout << "short = " << sizeof(unsigned short) << endl; 00037 cout << "int = " << sizeof(unsigned int) << endl; 00038 cout << "long long = " << sizeof(long long) << endl; 00039 00040 SGSocket s( "", "5500", "tcp" ); 00041 00042 if ( !s.open( SG_IO_BI ) ) { 00043 cout << "error can't open socket\n"; 00044 } 00045 00046 char buf[256]; 00047 00048 while ( true ) { 00049 if ( s.readline( buf, 256 ) > 0 ) { 00050 cout << "result = " << buf; 00051 } 00052 sleep(1); 00053 } 00054 }