-int SGSocket::write( char *buf, int length ) {
- bool error_condition = false;
-
-#ifdef _MSC_VER
- if ( _write(sock, buf, length) < 0 ) {
-#else
- if ( std::write(sock, buf, length) < 0 ) {
-#endif
- FG_LOG( FG_IO, FG_ALERT, "Error writing to socket: " << port );
- error_condition = true;
- }
-
-#if 0
- // check for any new client connection requests
- fd_set ready;
- FD_ZERO(&ready);
- FD_SET(sock, &ready);
- struct timeval tv;
- tv.tv_sec = 0;
- tv.tv_usec = 0;
-
- // test for any input on sock (returning immediately, even if
- // nothing)
- select(32, &ready, 0, 0, &tv);
-
- // any new connections?
- if ( FD_ISSET(sock, &ready) ) {
- int msgsock = accept(sock, 0, 0);
- if ( msgsock < 0 ) {
- FG_LOG( FG_IO, FG_ALERT,
- "Error: accept() failed in write()" );
- return 0;
- } else {
- client_connections.push_back( msgsock );
- }
+int
+SGSocket::write( const char *buf, const int length )
+{
+ simgear::Socket* s = client == 0 ? &sock : client;
+ if (s->getHandle() == -1)
+ {
+ return 0;