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