很简单的问题(10分)

  • 主题发起人 主题发起人 张无忌
  • 开始时间 开始时间

张无忌

Unregistered / Unconfirmed
GUEST, unregistred user!
sockBaw:=WSASocket(AF_INET, SOCK_RAW, IPPROTO_ICMP,NIL,0,0);
bopt:=TRUE; //设置自己填IP头选项
ret:=setsockopt(sockBaw,IPPROTO_IP,IP_HDRINCL,@bopt,
sizeof(bopt));
居然出错,怪,不知道是那出了问题
 
我是加的winsock2版本的DLL
 
返回的错误代码说参数不对,不知道是怎么了,错误出现在设置IP_HDRINCL以后
 
有没有知道的,我用的是WIN2000,我是用管理员身份上的呀
 
找到问题了,是DELPHI6的第2张光盘上的
哪个winsock2的PAS文件有问题,哎,要是DELPHI有VC那么多的资源就好了,哎~~~~~~~[:(!][:(!]
 
张无忌,我想拜你为师怎么样:
寄给我你的QQ号,和EMIAL好吗?



非凡
 
这个问题我找到答案了,是哪个boolean值应该改为longbool就OK了,
 
看看这个

function TelnetConn(var m_Socket: TSocket; Login: TTelnetLogin): Integer;
var
WSAData1: WSAData;
ServerTelnet: sockaddr_in;
nReturn: Integer;
Waittime: linger;
begin
WSAStartup(wVersionRequested, WSAData1);
m_Socket := INVALID_SOCKET;
ServerTelnet.sin_family := AF_INET;
ServerTelnet.sin_addr.s_addr := inet_addr(Login.IP);
ServerTelnet.sin_port := htons(Login.TelPort);
m_Socket := socket(AF_INET, SOCK_STREAM , 0);
nReturn := connect(m_Socket ,ServerTelnet, sizeof(sockaddr_in));
if nReturn = SOCKET_ERROR then
//ShowMessage('Network connenct error')
else
begin
Waittime.l_linger := 5;
Waittime.l_onoff := WORD(True);
setsockopt(m_Socket, SOL_SOCKET, SO_RCVTIMEO, PChar(TimeOut), sizeof(TimeOut));
setsockopt(m_Socket, SOL_SOCKET, SO_LINGER, PChar(TimeOut), sizeof(Waittime));
setsockopt(m_Socket, SOL_SOCKET, SO_REUSEADDR, nil, 0);
setsockopt(m_Socket, SOL_SOCKET, SO_KEEPALIVE, nil, 0);
Sleep(Wait);
FillChar(recvBuffer, recvlen, #0);
nReturn := recv(m_Socket, recvBuffer, recvlen, 0);
if nReturn <> SOCKET_ERROR then
begin
FillChar(sendBuffer, sendlen, #0);
StrCopy(sendBuffer, #255 + #252 + #35);
nReturn := send(m_Socket, sendBuffer, Strlen(sendBuffer), 0);
FillChar(sendBuffer, sendlen, #0);
StrCopy(sendBuffer, PChar(login.TelUsername + #13));
nReturn := send(m_Socket, sendBuffer, Strlen(sendBuffer), 0);
FillChar(recvBuffer, recvlen, #0);
nReturn := recv(m_Socket, recvBuffer, 1024, 0);
FillChar(sendBuffer, sendlen, #0);
StrCopy(sendBuffer, PChar(login.TelPassword + #13));
nReturn := send(m_Socket, sendBuffer, Strlen(sendBuffer), 0);
FillChar(recvBuffer, recvlen, #0);
Sleep(Wait);
nReturn := recv(m_Socket, recvBuffer, 1024, 0);
ShowMessage(recvBuffer);
end;
end;
WSACleanup();
end;
 
接受答案了.
 

Similar threads

D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
D
回复
0
查看
837
DelphiTeacher的专栏
D
I
回复
0
查看
668
import
I
后退
顶部