J
jnsd
Unregistered / Unconfirmed
GUEST, unregistred user!
你好hahali:我是jnsd,前两天你回答我的问题,
我试了一下你的程序,
连21端口的ftp时没问题,连23端口telnet
时出错,怎么回事啊,程序如下:
procedure TForm1.FormCreate(Sender: TObject);
begin
Memo1.Text:='';
Edit1.Text:='10.10.1.11';
Edit2.Text:='23';
ClientSocket1.ClientType:=ctNonBlocking;
if ClientSocket1.Active then exit;
ClientSocket1.Host:=Edit1.Text;
ClientSocket1.Port:=StrToInt(Edit2.Text);
ClientSocket1.Active:=True;
end;
procedure TForm1.ClientSocket1Read(Sender: TObject;
Socket: TCustomWinSocket);
var
bufchar;
count:integer;
begin
count:=Socket.ReceiveLength;
GetMem(buf,count+1);
ZeroMemory(buf,count+1);
Socket.ReceiveBuf(buf^,count);
Memo1.Lines.Add(buf);
FreeMem(buf);
end;
procedure TForm1.Button3Click(Sender: TObject);
var
bufchar;
count:integer;
sBuf:string;
begin
sBuf:=Edit3.Text+#13+#10;
count:=length(sBuf);
GetMem(buf,count+1);
ZeroMemory(buf,count+1);
StrPCopy(buf,sBuf);
ClientSocket1.Socket.SendBuf(buf^,count);
FreeMem(buf);
Edit3.Text:='';
end;
我试过的,可以。如果你想要让程序自动执行这些命令的,可以设置一个定时器呀
然后将Edit3中的内容变换成你所要的执行的命令,并且要让该按钮随着Edit3
内容的改变自动执行。
我试了一下你的程序,
连21端口的ftp时没问题,连23端口telnet
时出错,怎么回事啊,程序如下:
procedure TForm1.FormCreate(Sender: TObject);
begin
Memo1.Text:='';
Edit1.Text:='10.10.1.11';
Edit2.Text:='23';
ClientSocket1.ClientType:=ctNonBlocking;
if ClientSocket1.Active then exit;
ClientSocket1.Host:=Edit1.Text;
ClientSocket1.Port:=StrToInt(Edit2.Text);
ClientSocket1.Active:=True;
end;
procedure TForm1.ClientSocket1Read(Sender: TObject;
Socket: TCustomWinSocket);
var
bufchar;
count:integer;
begin
count:=Socket.ReceiveLength;
GetMem(buf,count+1);
ZeroMemory(buf,count+1);
Socket.ReceiveBuf(buf^,count);
Memo1.Lines.Add(buf);
FreeMem(buf);
end;
procedure TForm1.Button3Click(Sender: TObject);
var
bufchar;
count:integer;
sBuf:string;
begin
sBuf:=Edit3.Text+#13+#10;
count:=length(sBuf);
GetMem(buf,count+1);
ZeroMemory(buf,count+1);
StrPCopy(buf,sBuf);
ClientSocket1.Socket.SendBuf(buf^,count);
FreeMem(buf);
Edit3.Text:='';
end;
我试过的,可以。如果你想要让程序自动执行这些命令的,可以设置一个定时器呀
然后将Edit3中的内容变换成你所要的执行的命令,并且要让该按钮随着Edit3
内容的改变自动执行。