|
Last change
on this file since 650 was 502, checked in by frichard, 15 years ago |
|
-BAOControl : petite interface permettant de contrôler les antennes via le pilote indi_BAO
-Le pilote indi_BAO utilise désormais indilib v 0.7
|
-
Property svn:executable
set to
*
|
|
File size:
895 bytes
|
| Line | |
|---|
| 1 | // Definition of the Socket class
|
|---|
| 2 |
|
|---|
| 3 | #ifndef Socket_class
|
|---|
| 4 | #define Socket_class
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 | #include <sys/types.h>
|
|---|
| 8 | #include <sys/socket.h>
|
|---|
| 9 | #include <netinet/in.h>
|
|---|
| 10 | #include <netdb.h>
|
|---|
| 11 | #include <unistd.h>
|
|---|
| 12 | #include <string>
|
|---|
| 13 | #include <arpa/inet.h>
|
|---|
| 14 | #include <iostream>
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 | const int MAXHOSTNAME = 200;
|
|---|
| 18 | const int MAXCONNECTIONS = 5;
|
|---|
| 19 | const int MAXRECV = 5000;
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 | class Socket
|
|---|
| 24 | {
|
|---|
| 25 | public:
|
|---|
| 26 | Socket();
|
|---|
| 27 | virtual ~Socket();
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 | // Server initialization
|
|---|
| 31 | bool create();
|
|---|
| 32 | bool bind ( const int port );
|
|---|
| 33 | bool listen() const;
|
|---|
| 34 | bool accept ( Socket& ) const;
|
|---|
| 35 |
|
|---|
| 36 | // Client initialization
|
|---|
| 37 | bool connect ( const std::string host, const int port );
|
|---|
| 38 |
|
|---|
| 39 | // Data Transimission
|
|---|
| 40 | bool send ( const std::string ) const;
|
|---|
| 41 | int recv ( std::string& ) const;
|
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 | void set_non_blocking ( const bool );
|
|---|
| 45 |
|
|---|
| 46 | bool is_valid() const { return m_sock != -1; }
|
|---|
| 47 |
|
|---|
| 48 | bool shutdown();
|
|---|
| 49 |
|
|---|
| 50 | private:
|
|---|
| 51 |
|
|---|
| 52 | int m_sock;
|
|---|
| 53 | sockaddr_in m_addr;
|
|---|
| 54 |
|
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 | };
|
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 | #endif
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.