diff --git a/Engine/Server.C b/Engine/Server.C index 1cda3bd..a92a038 100644 --- a/Engine/Server.C +++ b/Engine/Server.C @@ -31,6 +31,10 @@ #include /* Generic TCP server class */ + +/* */ + + #define MAX_HOST_NAME 512 /** open a socket listening on TCP port /port/. Returns -1 in case of error. */ @@ -154,21 +158,23 @@ Server::run ( void ) } else { - /* echo to others */ - for ( int j = maxfd; j-- ; ) - { - if ( ! FD_ISSET( j, &master ) ) - continue; - if ( j != server && j != i ) + if ( echos() ) + /* echo to others */ + for ( int j = maxfd; j-- ; ) { - if ( send( j, buf, l, 0 ) < 0 ) - perror( "send()" ); + if ( ! FD_ISSET( j, &master ) ) + continue; + + if ( j != server && j != i ) + { + if ( send( j, buf, l, 0 ) < 0 ) + perror( "send()" ); + } } - } buf[ l ] = '\0'; - handle_request( buf, l ); + handle_request( i, buf, l ); } } } diff --git a/Engine/Server.H b/Engine/Server.H index 77b1e08..28bdb30 100644 --- a/Engine/Server.H +++ b/Engine/Server.H @@ -31,7 +31,9 @@ public: protected: + virtual bool echos ( void ) { return true; } + virtual void handle_hang_up ( int s ) = 0; virtual void handle_new ( int s ) = 0; - virtual void handle_request ( const char *s, int l ) = 0; + virtual void handle_request ( int s, const char *s, int l ) = 0; }; diff --git a/Engine/Timeline_Server.C b/Engine/Timeline_Server.C index fa78f63..e59bbfd 100644 --- a/Engine/Timeline_Server.C +++ b/Engine/Timeline_Server.C @@ -26,6 +26,8 @@ #include "Timeline_Server.H" #include +#include +#include /* Timeline Server. @@ -65,7 +67,9 @@ Timeline_Server::handle_hang_up ( int s ) } void -Timeline_Server::handle_request ( const char *s, int l ) +Timeline_Server::handle_request ( int s, const char *buf, int l ) { - printf( "request: %s", s ); + printf( "request: %s", buf ); + + send( s, "fuckoff\n", strlen( "fuckoff\n" ), 0 ); } diff --git a/Engine/Timeline_Server.H b/Engine/Timeline_Server.H index 1865f86..86e5b45 100644 --- a/Engine/Timeline_Server.H +++ b/Engine/Timeline_Server.H @@ -28,7 +28,7 @@ protected: void handle_new ( int s ); void handle_hang_up ( int s ); - void handle_request ( const char *s, int l ); + void handle_request ( int s, const char *s, int l ); public: