读书人

Delphi中SIO_UDP_CONNRESET如何定义

发布时间: 2013-08-01 15:23:18 作者: rapoo

Delphi中SIO_UDP_CONNRESET怎么定义?
用IdUDPServer想修正返回10054错误,从僵哥那抄来了Delphi版解决代码,不过不知道在Delphi中SIO_UDP_CONNRESET怎么定义,请大神指点迷津!
微软解决方案中定义#define SIO_UDP_CONNRESET _WSAIOW(IOC_VENDOR,12)
http://support.microsoft.com/kb/263823
附代码(来自僵哥)
function AllowUdpConnReset(Sd:TSocket;bNewBehavior:BOOL):BOOL;
var
dwBytesReturned:DWORD ;
status:Integer;
dwErr:DWORD ;
begin
Result := False;
dwBytesReturned := 0;
// disable new behavior using
// IOCTL: SIO_UDP_CONNRESET
status := WSAIoctl( sd, SIO_UDP_CONNRESET,
@bNewBehavior, sizeof(bNewBehavior),
Nil, 0, @dwBytesReturned,
Nil, Nil);
if (SOCKET_ERROR = status) then
begin
dwErr := WSAGetLastError();
if (WSAEWOULDBLOCK = dwErr) then
begin
// nothing to do
Exit;
end
else
begin
Exit;
end;
end;
Result := True;
end;
[解决办法]
#define SIO_UDP_CONNRESET _WSAIOW(IOC_VENDOR,12)

翻译为:
const
SIO_UDP_CONNRESET = $80000000 or $18000000 or 1;

读书人网 >.NET

热点推荐