]> git.mxchange.org Git - simgear.git/blob - simgear/io/socktest.cxx
471f0ad6ca06b32cfc5f3406c8547b9e348e57a7
[simgear.git] / simgear / io / socktest.cxx
1 #include <unistd.h>
2
3 #include "sg_socket.hxx"
4 #include "lowlevel.hxx"
5
6 static const int sgEndianTest = 1;
7 #define sgIsLittleEndian (*((char *) &sgEndianTest ) != 0)
8 #define sgIsBigEndian    (*((char *) &sgEndianTest ) == 0)
9
10 int main() {
11
12     if ( sgIsLittleEndian ) {
13        cout << "this machine is little endian\n";
14     }
15
16     if ( sgIsBigEndian ) {
17        cout << "this machine is big endian\n";
18     }
19
20     cout << "short = " << sizeof(unsigned short) << endl;
21     cout << "int = " << sizeof(unsigned int) << endl;
22     cout << "long long = " << sizeof(long long) << endl;
23
24     SGSocket s( "", "5500", "tcp" );
25
26     if ( !s.open( SG_IO_BI ) ) {
27         cout << "error can't open socket\n";
28     }
29
30     char buf[256];
31
32     while ( true ) {
33         if ( s.readline( buf, 256 ) > 0 ) {
34             cout << "result = " << buf;
35         }
36         sleep(1);
37     }
38 }