P
phpexpert
Unregistered / Unconfirmed
GUEST, unregistred user!
我的代码如下,但是memo1中并没有任何反馈信息,不知道是什么问题?
如果我点了多次button,它会提示主机放弃一个已连接的连接。
恳请指教~~
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ScktComp, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
ClientSocket1: TClientSocket;
procedure Button1Click(Sender: TObject);
procedure ClientSocket1Read(Sender: TObject; Socket: TCustomWinSocket);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
CR:string;
begin
CR:=#13+#10;
//ClientSocket1.Address := '192.168.0.15';
ClientSocket1.ClientType := ctBlocking;
ClientSocket1.Port := 9019;
ClientSocket1.Active := true;
ClientSocket1.Socket.SendText('post /login HTTP/1.1'+CR);
ClientSocket1.Socket.SendText('Accept:*/*'+CR);
ClientSocket1.Socket.SendText('Accept-Language: zh-cn'+CR);
ClientSocket1.Socket.SendText('referer:http://192.168.0.15/login'+CR);
ClientSocket1.Socket.SendText('Content-type:application/x-www-form-urlencoded'+CR);
ClientSocket1.Socket.SendText('User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)'+CR);
ClientSocket1.Socket.SendText('Host: 192.168.0.15:9019'+CR);
ClientSocket1.Socket.SendText('Content-length:16'+CR);
ClientSocket1.Socket.SendText('Connection: Keep-Alive'+CR);
ClientSocket1.Socket.SendText(CR);
end;
procedure TForm1.ClientSocket1Read(Sender: TObject;
Socket: TCustomWinSocket);
begin
memo1.Lines.Add(ClientSocket1.Socket.ReceiveText);
end;
end.
如果我点了多次button,它会提示主机放弃一个已连接的连接。
恳请指教~~
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ScktComp, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
ClientSocket1: TClientSocket;
procedure Button1Click(Sender: TObject);
procedure ClientSocket1Read(Sender: TObject; Socket: TCustomWinSocket);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
CR:string;
begin
CR:=#13+#10;
//ClientSocket1.Address := '192.168.0.15';
ClientSocket1.ClientType := ctBlocking;
ClientSocket1.Port := 9019;
ClientSocket1.Active := true;
ClientSocket1.Socket.SendText('post /login HTTP/1.1'+CR);
ClientSocket1.Socket.SendText('Accept:*/*'+CR);
ClientSocket1.Socket.SendText('Accept-Language: zh-cn'+CR);
ClientSocket1.Socket.SendText('referer:http://192.168.0.15/login'+CR);
ClientSocket1.Socket.SendText('Content-type:application/x-www-form-urlencoded'+CR);
ClientSocket1.Socket.SendText('User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)'+CR);
ClientSocket1.Socket.SendText('Host: 192.168.0.15:9019'+CR);
ClientSocket1.Socket.SendText('Content-length:16'+CR);
ClientSocket1.Socket.SendText('Connection: Keep-Alive'+CR);
ClientSocket1.Socket.SendText(CR);
end;
procedure TForm1.ClientSocket1Read(Sender: TObject;
Socket: TCustomWinSocket);
begin
memo1.Lines.Add(ClientSocket1.Socket.ReceiveText);
end;
end.