📄 modbusconnection.h
字号:
#pragma once
#include <winsock2.h>
// Arbitrary max number of concurrent client connections
#define MAX_CLIENTS 4
// "Connection Info" structure
typedef struct tagCONNINFO
{
SOCKET socket;
CHAR szAddr[sizeof "255.255.255.255:65535"]; // client's IP address
DWORD dwLastTime; // time of last transaction with client
DWORD dwRcvd; // total number of bytes received
DWORD dwSent; // total number of bytes sent
DWORD dwGood; // total number of accepted client requests
DWORD dwBad; // total number of rejected client requests
} CONNINFO, *LPCONNINFO;
// CONNECTION structure
typedef struct tagCONNECTION
{
CRITICAL_SECTION cs; // Critical Section for access control to CONNINFO
CONNINFO ci; // 'Connection Info' for the connection
HANDLE hStop; // 'Stop' event object for the connection
} CONNECTION, *LPCONNECTION;
class CModbusConnection
{
public:
CModbusConnection(void);
~CModbusConnection(void);
static void CreateConnections( void );
static void DeleteConnections( void );
static void EnableConnections( void );
static void DisableConnections( void );
static HANDLE OpenConnection( SOCKET socket, LPSOCKADDR_IN lpSocketAddr );
static void CloseConnection( HANDLE hConn );
static void GetConnInfo( INT idConn, LPCONNINFO lpInfo );
static void IncrementConnCounters( HANDLE hConn, BOOL fGoodRequest, WORD wRcvd, WORD wSent );
static SOCKET GetConnSocket( HANDLE hConn );
static HANDLE GetConnStopEvent( HANDLE hConn );
// Array of client connections
static CONNECTION connections[MAX_CLIENTS];
// Count of free (closed) client connections
static HANDLE hFreeConnections;
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -