Action_Thermostats
Adding_MD_integration_tests
Adding_StructOpt_integration_tests
AutomationFragmentation_failures
Candidate_v1.6.1
ChemicalSpaceEvaluator
Enhanced_StructuralOptimization
Enhanced_StructuralOptimization_continued
Exclude_Hydrogens_annealWithBondGraph
Fix_Verbose_Codepatterns
ForceAnnealing_with_BondGraph
ForceAnnealing_with_BondGraph_continued
ForceAnnealing_with_BondGraph_continued_betteresults
ForceAnnealing_with_BondGraph_contraction-expansion
Gui_displays_atomic_force_velocity
JobMarket_RobustOnKillsSegFaults
JobMarket_StableWorkerPool
PythonUI_with_named_parameters
Recreated_GuiChecks
StoppableMakroAction
TremoloParser_IncreasedPrecision
Rev | Line | |
---|
[0b990d] | 1 | #ifdef __GNUG__
|
---|
| 2 | #pragma interface
|
---|
| 3 | #endif
|
---|
| 4 |
|
---|
| 5 | #ifndef _socket_h
|
---|
| 6 | #define _socket_h
|
---|
| 7 |
|
---|
| 8 | #include <unistd.h>
|
---|
| 9 | #include <sys/types.h>
|
---|
| 10 |
|
---|
| 11 | #include <string>
|
---|
| 12 |
|
---|
| 13 | class TCPSocket {
|
---|
| 14 | protected:
|
---|
| 15 | TCPSocket();
|
---|
| 16 | virtual ~TCPSocket();
|
---|
| 17 |
|
---|
| 18 | int socket_;
|
---|
| 19 | int port_;
|
---|
| 20 | bool initialized_;
|
---|
| 21 | bool bound_;
|
---|
| 22 |
|
---|
| 23 | public:
|
---|
| 24 | void create();
|
---|
| 25 | void bind(u_int16_t port_begin, u_int16_t port_fence);
|
---|
| 26 | int port() { return port_; }
|
---|
| 27 | u_int32_t addr();
|
---|
| 28 |
|
---|
| 29 | bool initialized() { return initialized_; }
|
---|
| 30 | bool bound() { return bound_; }
|
---|
| 31 |
|
---|
| 32 | virtual void close();
|
---|
| 33 | };
|
---|
| 34 |
|
---|
| 35 | class TCPIOSocket: public TCPSocket {
|
---|
| 36 | public:
|
---|
| 37 | int read(void *d, int n);
|
---|
| 38 | int write(const void *d, int n);
|
---|
| 39 | int read_int(int *d, int n) {return read((void*)d,n*sizeof(int));}
|
---|
| 40 | int write_int(const int *d, int n) {return write((void*)d,n*sizeof(int));}
|
---|
| 41 | int read_string(std::string &);
|
---|
| 42 | int write_string(const std::string &);
|
---|
| 43 | int read_int(int &);
|
---|
| 44 | int write_int(int);
|
---|
| 45 | int read_uint32(u_int32_t &);
|
---|
| 46 | int write_uint32(u_int32_t);
|
---|
| 47 | };
|
---|
| 48 |
|
---|
| 49 | class TCPServerSocket: public TCPSocket {
|
---|
| 50 | friend class TCPServerConnection;
|
---|
| 51 | public:
|
---|
| 52 | void listen(int queue_length = 8);
|
---|
| 53 | };
|
---|
| 54 |
|
---|
| 55 | class TCPServerConnection: public TCPIOSocket {
|
---|
| 56 | public:
|
---|
| 57 | void accept(const TCPServerSocket &);
|
---|
| 58 | };
|
---|
| 59 |
|
---|
| 60 | class TCPClientConnection: public TCPIOSocket {
|
---|
| 61 | bool connected_;
|
---|
| 62 | public:
|
---|
| 63 | TCPClientConnection();
|
---|
| 64 | void close();
|
---|
| 65 | bool connected() { return connected_; }
|
---|
| 66 | void connect(const char *remote_hostname, u_int16_t remote_port);
|
---|
| 67 | void connect(u_int32_t remote_host, u_int16_t remote_port);
|
---|
| 68 | };
|
---|
| 69 |
|
---|
| 70 | #endif
|
---|
Note:
See
TracBrowser
for help on using the repository browser.