base
This commit is contained in:
+57
@@ -0,0 +1,57 @@
|
||||
|
||||
#ifndef _ETHERNET_H_
|
||||
#define _ETHERNET_H_
|
||||
|
||||
#include "commdef.h"
|
||||
#include "interface.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "Winsock2.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
class ARCLIB_API EthernetInterface : public ArcInterface
|
||||
#else
|
||||
class EthernetInterface : public ArcInterface
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
EthernetInterface();
|
||||
~EthernetInterface();
|
||||
bool init(const char *szIPAddr, short nPort = 7890);
|
||||
int send(sIF_CMD_BLOCK *ifData);
|
||||
int recv(sIF_CMD_BLOCK *ifData);
|
||||
int syncSend(sIF_CMD_BLOCK *ifData);
|
||||
int getMTU();
|
||||
|
||||
// helper functions
|
||||
public:
|
||||
void *getDeviceHandle();
|
||||
SOCKET getSocket();
|
||||
|
||||
private:
|
||||
BOOL ClearReadBuffer();
|
||||
BOOL ClearWriteBuffer();
|
||||
BOOL ClearReadWriteBuffer();
|
||||
int WaitForReply(SOCKET s, long time_sec, long time_usec);
|
||||
SOCKET m_socket;
|
||||
#ifdef _WIN32
|
||||
CRITICAL_SECTION m_cs;
|
||||
void requirelock()
|
||||
{
|
||||
EnterCriticalSection(&m_cs);
|
||||
}
|
||||
void releaselock()
|
||||
{
|
||||
LeaveCriticalSection(&m_cs);
|
||||
}
|
||||
#elif defined(__unix_like__)
|
||||
|
||||
#endif
|
||||
struct sockaddr_in agentaddr;
|
||||
struct sockaddr_in manager_addr;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user