]> git.mxchange.org Git - simgear.git/blob - simgear/io/socktest.cxx
Tweaks in preparation for the 0.3.6-pre1 release.
[simgear.git] / simgear / io / socktest.cxx
1 #include <simgear/compiler.h>
2
3 #include <unistd.h>
4 #include STL_IOSTREAM
5
6 #include "sg_socket.hxx"
7 #include "lowlevel.hxx"
8
9 static const int sgEndianTest = 1;
10 #define sgIsLittleEndian (*((char *) &sgEndianTest ) != 0)
11 #define sgIsBigEndian    (*((char *) &sgEndianTest ) == 0)
12
13 SG_USING_STD(cout);
14 SG_USING_STD(endl);
15
16
17 int main() {
18
19     if ( sgIsLittleEndian ) {
20        cout << "this machine is little endian\n";
21     }
22
23     if ( sgIsBigEndian ) {
24        cout << "this machine is big endian\n";
25     }
26
27     cout << "short = " << sizeof(unsigned short) << endl;
28     cout << "int = " << sizeof(unsigned int) << endl;
29     cout << "long long = " << sizeof(long long) << endl;
30
31     SGSocket s( "", "5500", "tcp" );
32
33     if ( !s.open( SG_IO_BI ) ) {
34         cout << "error can't open socket\n";
35     }
36
37     char buf[256];
38
39     while ( true ) {
40         if ( s.readline( buf, 256 ) > 0 ) {
41             cout << "result = " << buf;
42         }
43 #ifdef __MINGW32__
44         Sleep(100);
45 #else
46         sleep(1);
47 #endif
48     }
49 }