| 
            Last change
 on this file since 676 was             495, checked in by frichard, 15 years ago           | 
        
        
          | 
             
-Le programme envoie désormais les ordres GOTO en mode relatif 
-Il est possible de modifier la fréquence d'actualisation des modes tracking/transit depuis la boite de dialogue d'INDI 
 
           | 
        
        
          | 
            File size:
            1.2 KB
           | 
        
      
      
| Line |   | 
|---|
| 1 | // Implementation of the ServerSocket class
 | 
|---|
| 2 | 
 | 
|---|
| 3 | #include "ServerSocket.h"
 | 
|---|
| 4 | #include "SocketException.h"
 | 
|---|
| 5 | 
 | 
|---|
| 6 | 
 | 
|---|
| 7 | ServerSocket::ServerSocket ( int port )
 | 
|---|
| 8 | {
 | 
|---|
| 9 |   if ( ! Socket::create() )
 | 
|---|
| 10 |     {
 | 
|---|
| 11 |       throw SocketException ( "Could not create server socket." );
 | 
|---|
| 12 |     }
 | 
|---|
| 13 | 
 | 
|---|
| 14 |   if ( ! Socket::bind ( port ) )
 | 
|---|
| 15 |     {
 | 
|---|
| 16 |       throw SocketException ( "Could not bind to port." );
 | 
|---|
| 17 |     }
 | 
|---|
| 18 | 
 | 
|---|
| 19 |   if ( ! Socket::listen() )
 | 
|---|
| 20 |     {
 | 
|---|
| 21 |       throw SocketException ( "Could not listen to socket." );
 | 
|---|
| 22 |     }
 | 
|---|
| 23 | //Socket::set_non_blocking(true);
 | 
|---|
| 24 | }
 | 
|---|
| 25 | 
 | 
|---|
| 26 | ServerSocket::~ServerSocket()
 | 
|---|
| 27 | {
 | 
|---|
| 28 | }
 | 
|---|
| 29 | 
 | 
|---|
| 30 | 
 | 
|---|
| 31 | const ServerSocket& ServerSocket::operator << ( const std::string& s ) const
 | 
|---|
| 32 | {
 | 
|---|
| 33 |   if ( ! Socket::send ( s ) )
 | 
|---|
| 34 |     {
 | 
|---|
| 35 |       throw SocketException ( "Could not write to socket." );
 | 
|---|
| 36 |     }
 | 
|---|
| 37 | 
 | 
|---|
| 38 |   return *this;
 | 
|---|
| 39 | 
 | 
|---|
| 40 | }
 | 
|---|
| 41 | 
 | 
|---|
| 42 | 
 | 
|---|
| 43 | const ServerSocket& ServerSocket::operator >> ( std::string& s ) const
 | 
|---|
| 44 | {
 | 
|---|
| 45 |   if ( ! Socket::recv ( s ) )
 | 
|---|
| 46 |     {
 | 
|---|
| 47 |      throw SocketException ( "Could not read from socket." );
 | 
|---|
| 48 |     }
 | 
|---|
| 49 | 
 | 
|---|
| 50 |   return *this;
 | 
|---|
| 51 | }
 | 
|---|
| 52 | 
 | 
|---|
| 53 | void ServerSocket::accept ( ServerSocket& sock )
 | 
|---|
| 54 | {
 | 
|---|
| 55 |   if ( ! Socket::accept ( sock ) )
 | 
|---|
| 56 |     {
 | 
|---|
| 57 |       throw SocketException ( "Could not accept socket." );
 | 
|---|
| 58 |     }
 | 
|---|
| 59 | }
 | 
|---|
| 60 | 
 | 
|---|
| 61 | void ServerSocket::recv( std::string& s ) 
 | 
|---|
| 62 | {
 | 
|---|
| 63 |   if ( ! Socket::recv ( s ) )
 | 
|---|
| 64 |     {
 | 
|---|
| 65 |     throw SocketException ( "Could  not read from socket." );
 | 
|---|
| 66 |     }
 | 
|---|
| 67 | }
 | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.