具体代码在 : http://download.csdn.net/detail/warrially/6414989 有兴趣的可以看看.
第二版 http://download.csdn.net/detail/warrially/6534653
2019年3月 不知道为什么 CSDN 要收费了. 把代码放到git上了
https://gitee.com/warrially/RaknetForDelphi
interface DECLSPEC_UUID("4352F36E-5A07-4B9B-8D03-E0254584AC48")
IRaknetClient : public IUnknown
{
public:
virtual char* __stdcall GetIpAddress() = NULL;
virtual void __stdcall SetIpAddress(char* lpszMsg) = NULL;
virtual int __stdcall GetPort() = NULL;
virtual void __stdcall SetPort(int nValue) = NULL;
virtual int __stdcall GetMaxConnect() = NULL;
virtual void __stdcall SetMaxConnect(int nValue) = NULL;
virtual bool __stdcall RnOpen() = NULL;
virtual bool __stdcall RnClose() = NULL;
virtual bool __stdcall UdpRead(TRnUdpCallback OnUdpCallback) = NULL;
virtual int __stdcall UdpSend(const char* szBuf,int nLen) = NULL;
};
type
IRaknetClient = interface
['{4352F36E-5A07-4B9B-8D03-E0254584AC48}']
function GetIpAddress : PAnsiChar; stdcall;
procedure SetIpAddress(AValue : PAnsiChar); stdcall;
function GetPort : Integer; stdcall;
procedure SetPort(AValue : Integer); stdcall;
function GetMaxConnect : Integer; stdcall;
procedure SetMaxConnect(AValue : Integer); stdcall;
function RnOpen() : Boolean; stdcall;
function RnClose() : Boolean; stdcall;
function UdpRead(OnUdpCallback : TRnUdpCallback) : Boolean; stdcall;
function UdpSend(const szBuf : PAnsiChar; nLen : Integer)
: Integer; stdcall;
property IpAddress : PAnsiChar read GetIpAddress write SetIpAddress;
property Port : Integer read GetPort write SetPort;
property MaxConnect : Integer read GetMaxConnect write SetMaxConnect;
end;
interface DECLSPEC_UUID("0EA920B3-0404-4B4D-A5AD-D61460166532")
IRaknetServer : public IUnknown
{
public:
virtual char* __stdcall GetIpAddress() = NULL;
virtual void __stdcall SetIpAddress(char* lpszMsg) = NULL;
virtual int __stdcall GetPort() = NULL;
virtual void __stdcall SetPort(int nValue) = NULL;
virtual int __stdcall GetMaxConnect() = NULL;
virtual void __stdcall SetMaxConnect(int nValue) = NULL;
virtual int __stdcall GetMaxIncoming() = NULL;
virtual void __stdcall SetMaxIncoming(int nValue) = NULL;
virtual bool __stdcall RnOpen() = NULL;
virtual bool __stdcall RnClose() = NULL;
virtual bool __stdcall UdpRead(TRnUdpCallback OnUdpCallback) = NULL;
};
type
IRaknetServer = interface
['{0EA920B3-0404-4B4D-A5AD-D61460166532}']
function GetIpAddress : PAnsiChar; stdcall;
procedure SetIpAddress(AValue : PAnsiChar); stdcall;
function GetPort : Integer; stdcall;
procedure SetPort(AValue : Integer); stdcall;
function GetMaxConnect : Integer; stdcall;
procedure SetMaxConnect(AValue : Integer); stdcall;
function GetMaxIncoming : Integer; stdcall;
procedure SetMaxIncoming(AValue : Integer); stdcall;
function RnOpen() : Boolean; stdcall;
function RnClose() : Boolean; stdcall;
function UdpRead(OnUdpCallback : TRnUdpCallback) : Boolean; stdcall;
property IpAddress : PAnsiChar read GetIpAddress write SetIpAddress;
property Port : Integer read GetPort write SetPort;
property MaxConnect : Integer read GetMaxConnect write SetMaxConnect;
property MaxIncoming : Integer read GetMaxIncoming write SetMaxIncoming;
end;