- unit EdSockServerApi;
- //**********************************************************
- //深圳市东方数码技术有限公司
- //曾伟才
- //2004年11月9日
- //**********************************************************
- interface
- uses
- Windows;
- const
- //数据错误
- EDDATAERROR = 1000;
- //模块缓冲区溢出
- EDBUFOVERFLOW = 1001;
- //电脑接收缓冲区溢出,用于阻塞接收调用
- EDRECVBUFOVERFLOW = 1002;
- type
- TOnAccept = procedure (ConnectID: Longint); stdcall;
- TOnConnectClose = procedure (ConnectID: Longint); stdcall;
- TOnError = procedure (SocketID: Longint; ErrorCode: Longint); stdcall;
- TOnReceConfigData = procedure (ConnectID: Longint; pDataBuf: PByte; DataLength: Longint); stdcall;
- TOnReceFromCOM = procedure (ConnectID: Longint; COMNum: Longint; pDataBuf: PByte; DataLength: Longint); stdcall;
- TOnSwitchChange = procedure (ConnectID: Longint; PortNum: Longint; Value: Longint); stdcall;
- //附加
- function mac_ntoa(mac: PByte; maclen: Integer; strmac: PByte; strlen: Integer): Integer; stdcall;
- function net_ntoa(ipAddr: ULONG; str: PByte; strlen: Integer): Integer; stdcall;
- function GetLocalIP(ConnectID: Longint): ULONG; stdcall;
- function GetLocalPort(ConnectID: Longint): Longint; stdcall;
- function StartListen(LocalIP: LPCTSTR; LocalPort: Longint): BOOL; stdcall;
- function StopListen(): BOOL; stdcall;
- function CloseConnect(ConnectID: Longint): BOOL; stdcall;
- function GetError(SocketID: Longint): Longint; stdcall;
- function GetPeerIP(ConnectID: Longint): ULONG; stdcall;
- function GetPeerPort(ConnectID: Longint): Longint; stdcall;
- function OpenConnect(PeerIP: LPCTSTR; PeerPort: Longint; LocalIP: LPCTSTR; LocalPort: Longint): BOOL; stdcall;
- function GetMAC(ConnectID: Longint; lpMac: PByte; maclen: Integer): Integer; stdcall;
- function GetSwitchDirection(ConnectID: Longint; PortNum: Longint): Longint; stdcall;
- function SendToCOM(ConnectID: Longint; COMNum: Longint; pDataBuf: PByte; DataLength: Longint): BOOL; stdcall;
- function SetSwitchValue(ConnectID: Longint; PortNum: Longint; Value: Longint): BOOL; stdcall;
- function RequestConfigData(ConnectID: Longint): BOOL; stdcall;
- function SetConfigData(ConnectID: Longint; pDataBuf: pByte; DataLength: Longint): BOOL; stdcall;
- function GetSwitchValue(ConnectID: Longint; PortNum: Longint): Longint; stdcall;
- function ResetBoard(ConnectID: Longint): Longint; stdcall;
- function GetModel(ConnectID: Longint): Smallint; stdcall;
- function SetCOMPara(ConnectID: Longint; COMNum: Longint; pDataBuf: pByte; DataLength: Longint): BOOL; stdcall;
- function IsSocket(): BOOL; stdcall;
- function IsNoDelay(): BOOL; stdcall;
- function SetSocket(IsSocketValue: BOOL): BOOL; stdcall;
- function SetNoDelay(IsNoDelayValue: BOOL): BOOL; stdcall;
- function SetCallback(lpOnAccept: TOnAccept; lpOnConnectClose: TOnConnectClose; lpOnError:
- TOnError; lpOnReceConfigData: TOnReceConfigData; lpOnReceFromCOM: TOnReceFromCOM;
- lpOnSwitchChange: TOnSwitchChange): BOOL; stdcall;
- function CloseAllConnect(): BOOL; stdcall;
- function SetConnectOpt(ConnectID: Longint; level: Integer; optname: Integer;
- optval: PChar; optlen: Integer): BOOL; stdcall;
- function GetCOM(ConnectID: Longint): Integer; stdcall;
- function ReceiveData(ConnectID: Longint; pDataBuf: PByte; BufLen: Longint; dwWait: DWORD): Longint; stdcall;
- const
- EdSockServer = 'EdSockServer.dll';
- implementation
- function mac_ntoa; external EdSockServer name 'mac_ntoa';
- function net_ntoa; external EdSockServer name 'net_ntoa';
- function GetLocalIP; external EdSockServer name 'GetLocalIP';
- function GetLocalPort; external EdSockServer name 'GetLocalPort';
- function StartListen; external EdSockServer name 'StartListen';
- function StopListen; external EdSockServer name 'StopListen';
- function CloseConnect; external EdSockServer name 'CloseConnect';
- function GetError; external EdSockServer name 'GetError';
- function GetPeerIP; external EdSockServer name 'GetPeerIP';
- function GetPeerPort; external EdSockServer name 'GetPeerPort';
- function OpenConnect; external EdSockServer name 'OpenConnect';
- function GetMAC; external EdSockServer name 'GetMAC';
- function GetSwitchDirection; external EdSockServer name 'GetSwitchDirection';
- function SendToCOM; external EdSockServer name 'SendToCOM';
- function SetSwitchValue; external EdSockServer name 'SetSwitchValue';
- function RequestConfigData; external EdSockServer name 'RequestConfigData';
- function SetConfigData; external EdSockServer name 'SetConfigData';
- function GetSwitchValue; external EdSockServer name 'GetSwitchValue';
- function ResetBoard; external EdSockServer name 'ResetBoard';
- function GetModel; external EdSockServer name 'GetModel';
- function SetCOMPara; external EdSockServer name 'SetCOMPara';
- function IsSocket; external EdSockServer name 'IsSocket';
- function IsNoDelay; external EdSockServer name 'IsNoDelay';
- function SetSocket; external EdSockServer name 'SetSocket';
- function SetNoDelay; external EdSockServer name 'SetNoDelay';
- function SetCallback; external EdSockServer name 'SetCallback';
- function CloseAllConnect; external EdSockServer name 'CloseAllConnect';
- function SetConnectOpt; external EdSockServer name 'SetConnectOpt';
- function GetCOM; external EdSockServer name 'GetCOM';
- function ReceiveData; external EdSockServer name 'ReceiveData';
- end.