program Sender;
uses
Windows, ScktComp;
const
SendData ='POST /cgi-bin/internal/top/vote HTTP/1.1'#13#10+
'Accept: */*'#13#10'Referer: http://ent.sina.com.cn/v/f/sdxl/index.html'#13#10+
'Accept-Language: zh-cn'#13#10+
'Content-Type: application/x-www-form-urlencoded'#13#10+
'Accept-Encoding: gzip, deflate'#13#10+
'User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; Hotbar 4.4.6.0; .NET CLR 1.1.4322)'#13#10+
'Host: survey.sina.com.cn'#13#10+'Content-Length: 27'#13#10+
'Connection: Keep-Alive'#13#10+'Cache-Control: no-cache'#13#10+
'Cookie:'#13#10#13#10+'answer=1&id=9994&inv_type=1';
var
ClientSocket1 : TClientSocket;
MyNotifyEvent : TSocketNotifyEvent;
MyErrorEvent : TSocketErrorEvent ;
MyThreadMessage : tagMSG;
//----时钟回调----
procedure TimerProc( hwnd:HWND; uMsg:UINT; idEvent:UINT; dwTime
WORD );stdcall;
begin
if ClientSocket1.Active = True then ClientSocket1.Close;
ClientSocket1.Open;
end;
//----错误事件---- {--隐含参数--}
procedure ClientSocket1Error( Self: TObject; Sender: TObject; Socket: TCustomWinSocket;
ErrorEvent: TErrorEvent; var ErrorCode: Integer);
begin
ErrorCode:=0;
Socket.Close;
end;
//----连接事件---- {--隐含参数--}
procedure ClientSocket1Connect( Self: TObject; Sender: TObject;Socket: TCustomWinSocket);
begin
Socket.SendText(SendData);
Socket.SendText(SendData);
end;
//----------主程序-------
Begin
{--建立对象--}
ClientSocket1:=TClientSocket.Create(nil);
{--设置属性--}
if ClientSocket1.Active = True then ClientSocket1.Close;
ClientSocket1.ClientType:=ctNonBlocking ;
ClientSocket1.Host := 'survey.sina.com.cn' ;
ClientSocket1.Port := 80 ;
{--接事件处理过程--}
TMethod(MyErrorEvent).Code := @ClientSocket1Error;
TMethod(MyErrorEvent).Data := ClientSocket1;
ClientSocket1.OnError := MyErrorEvent;
TMethod(MyNotifyEvent).Code := @ClientSocket1Connect;
TMethod(MyNotifyEvent).Data := ClientSocket1;
ClientSocket1.OnConnect := MyNotifyEvent ;
{--安装时钟--}
SetTimer(0,0,2000,@TimerProc);
{--消息循环--}
While GetMessage(MyThreadMessage,0,0,0) do
DispatchMessage(MyThreadMessage);
end.