versadac  1
versadac - Scalable Recorder Firmware
mc_lockableSocket.h
1 /*******************************************************************************
2 FILE : mc_lockableSocket.h
3 VERSION : $Id: mc_lockableSocket.h 4938 2006-10-10 14:20:18Z martinto $
4 SYSTEM : __GNUC__ on vxworks
5 DESCRIPTION : Class for handling a locking of a socket for master comms.
6 *******************************************************************************/
7 
8 #ifndef __MC_LOCKABLESOCKET_H
9 #define __MC_LOCKABLESOCKET_H
10 #include "semLib.h"
11 #include "stdtypes.h"
12 
13 class mc_socketPool;
14 
16 {
17  friend class mc_socketPool;
18  public:
19  mc_lockableSocket(char * z_address, uint8 z_modbusAddress, bool z_share);
21  int *getFdPtr() { return &m_fd; };
22  bool lockIfFree() { return (semTake(m_lock, NO_WAIT)==OK)?TRUE:FALSE; };
23  void lock() { semTake(m_lock, WAIT_FOREVER); };
24  void unlock() { semGive(m_lock); };
25  bool match(char *z_address, uint8 z_modbusAddress, bool share);
26 
27  private:
28  char m_address[104];
29  double m_lastAccess;
30  mc_lockableSocket *m_next;
31  SEM_ID m_lock;
32  int m_fd;
33  bool m_share;
34  uint8 m_modbusAddress;
35 };
36 
37 #endif
Definition: mc_lockableSocket.h:15
Definition: mc_socketPool.h:15