Files
simgear/simgear/io/socktest.cxx
T
david 78411d29a7 Patch from Erik Hofman:
This patch adds some more functionality to the header files and removes
*all* dependencies on SG_HAVE_NATIVE_SGI_COMPILERS in the SimGear code!

[dpm: I had to add some additional SG_USING_STD declarations to make
it compile]
2002-12-31 14:47:34 +00:00

50 lines
966 B
C++

#include <simgear/compiler.h>
#include <unistd.h>
#include STL_IOSTREAM
#include "sg_socket.hxx"
#include "lowlevel.hxx"
static const int sgEndianTest = 1;
#define sgIsLittleEndian (*((char *) &sgEndianTest ) != 0)
#define sgIsBigEndian (*((char *) &sgEndianTest ) == 0)
SG_USING_STD(cout);
SG_USING_STD(endl);
int main() {
if ( sgIsLittleEndian ) {
cout << "this machine is little endian\n";
}
if ( sgIsBigEndian ) {
cout << "this machine is big endian\n";
}
cout << "short = " << sizeof(unsigned short) << endl;
cout << "int = " << sizeof(unsigned int) << endl;
cout << "long long = " << sizeof(long long) << endl;
SGSocket s( "", "5500", "tcp" );
if ( !s.open( SG_IO_BI ) ) {
cout << "error can't open socket\n";
}
char buf[256];
while ( true ) {
if ( s.readline( buf, 256 ) > 0 ) {
cout << "result = " << buf;
}
#ifdef __MINGW32__
Sleep(100);
#else
sleep(1);
#endif
}
}