source: BAORadio/libindi/v1/drivers/telescope/Socket.h@ 689

Last change on this file since 689 was 493, checked in by frichard, 15 years ago

Le programme gère mieux les connexion/déconnexion des microcontrôleurs.

File size: 907 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
15
16const int MAXHOSTNAME = 501;
17const int MAXCONNECTIONS = 254;
18const int MAXRECV = 1024;
19
20
21class Socket
22{
23 public:
24 Socket();
25 virtual ~Socket();
26
27 // Server initialization
28 bool create();
29 bool bind ( const int port );
30 bool listen() const;
31 bool accept ( Socket& ) const;
32
33 // Client initialization
34 bool connect ( const std::string host, const int port );
35
36 // Data Transimission
37 bool send ( const std::string ) const;
38 int recv ( std::string& ) const;
39
40 std::string recupip() const;
41
42 void set_non_blocking ( const bool );
43
44 bool is_valid() const { return m_sock != -1; }
45
46 bool shutdown();
47
48 private:
49
50 int m_sock;
51 sockaddr_in m_addr;
52
53};
54
55
56#endif
Note: See TracBrowser for help on using the repository browser.