source: BAORadio/libindi/libindi/BAOControl/Socket.h @ 504

Last change on this file since 504 was 504, checked in by frichard, 13 years ago

-Version 0.8 de libini
-Formule de Marc
-Nouvelles fonctionnalités (goto nom-de l'objet etc...)

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