Some cygwin32 portability fixes for fg_socket.cxx.
}
+// write null terminated string to a file
+int FGFile::writestring( char *str ) {
+ int length = strlen( str );
+ return write( str, length );
+}
+
+
// close the port
bool FGFile::close() {
if ( std::close( fp ) == -1 ) {
// write data to a file
int write( char *buf, int length );
+ // write null terminated string to a file
+ int writestring( char *str );
+
// close file
bool close();
}
+// write null terminated string to port
+int FGSerial::writestring( char *str ) {
+ int length = strlen( str );
+ return write( str, length );
+}
+
+
// close the port
bool FGSerial::close() {
if ( ! port.close_port() ) {
// read a line of data, length is max size of input buffer
int readline( char *buf, int length );
- // write data to a file
+ // write data to port
int write( char *buf, int length );
+ // write null terminated string to port
+ int writestring( char *str );
+
// close port
bool close();
#include <sys/types.h> // socket(), bind(), select(), accept()
#include <sys/socket.h> // socket(), bind(), listen(), accept()
#include <netinet/in.h> // struct sockaddr_in
-#include <netinet/tcp.h> // #define TCP_NODELAY, this attempts to
- // disable the Nagle algorithm.
#include <netdb.h> // gethostbyname()
#include <unistd.h> // select(), fsync()/fdatasync()
int FGSocket::make_server_socket () {
struct sockaddr_in name;
+
+#if defined( __CYGWIN__ ) || defined( __CYGWIN32__ )
+ int length;
+#else
socklen_t length;
+#endif
// Create the socket.
sock = socket (PF_INET, SOCK_STREAM, 0);
// Connect this socket to the host and the port specified on the
// command line
+#if defined( __CYGWIN__ ) || defined( __CYGWIN32__ )
+ bcopy(hp->h_addr, (char *)(&(name.sin_addr.s_addr)), hp->h_length);
+#else
bcopy(hp->h_addr, &(name.sin_addr.s_addr), hp->h_length);
+#endif
name.sin_port = htons(port);
if ( connect(sock, (struct sockaddr *) &name,
}
+// write null terminated string to socket (server)
+int FGSocket::writestring( char *str ) {
+ int length = strlen( str );
+ return write( str, length );
+}
+
+
// close the port
bool FGSocket::close() {
for ( int i = 0; i < (int)client_connections.size(); ++i ) {
// open the file based on specified direction
bool open( FGProtocol::fgProtocolDir dir );
- // read data from file
+ // read data from socket
int read( char *buf, int length );
- // read data from file
+ // read data from socket
int readline( char *buf, int length );
- // write data to a file
+ // write data to a socket
int write( char *buf, int length );
+ // write null terminated string to a socket
+ int writestring( char *str );
+
// close file
bool close();
}
+// dummy process routine
+int FGIOChannel::writestring( char *str ) {
+ return false;
+}
+
+
// dummy close routine
bool FGIOChannel::close() {
return false;
virtual int read( char *buf, int length );
virtual int readline( char *buf, int length );
virtual int write( char *buf, int length );
+ virtual int writestring( char *str );
virtual bool close();
};