29.08.2012, 20:19
|
|
Let Me Show You
|
|
Регистрация: 30.04.2010
Адрес: Северодвинск
Сообщения: 5,426
Версия Delphi: 7, XE5
Репутация: 59586
|
|
все работает:
Unit1.pas
Код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ScktComp;
type
TForm1 = class(TForm)
Memo1: TMemo;
Memo2: TMemo;
ServerSocket1: TServerSocket;
procedure ServerSocket1ClientRead(Sender: TObject;
Socket: TCustomWinSocket);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.ServerSocket1ClientRead(Sender: TObject;
Socket: TCustomWinSocket);
begin
Memo2.Lines.Add(Socket.ReceiveText);
Socket.SendText('HTTP/1.1 200 OK'#13#10);
Socket.SendText('Content-Type: text/html'#13#10);
Socket.SendText('Content-Length: '+IntToStr(Length(Memo1.Text))+#13#10);
Socket.SendText(#13#10);
Socket.SendText(Memo1.Text);
end;
end.
Unit1.dfm
Код:
object Form1: TForm1
Left = 192
Top = 124
Width = 870
Height = 640
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
FormStyle = fsStayOnTop
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Memo1: TMemo
Left = 80
Top = 64
Width = 489
Height = 225
Lines.Strings = (
'<html>'
' <body>'
' Hello!<br>'
' <script type="text/javascript">'
' for(i = 0; i < 10; i++){'
' document.write(''i = '' + i)'
' document.write(''<br>'')'
' }'
' </script>'
' </body>'
'</html>')
TabOrder = 0
WordWrap = False
end
object Memo2: TMemo
Left = 80
Top = 320
Width = 489
Height = 233
TabOrder = 1
end
object ServerSocket1: TServerSocket
Active = True
Port = 8081
ServerType = stNonBlocking
OnClientRead = ServerSocket1ClientRead
Left = 664
Top = 208
end
end
http://localhost:8081/
__________________
Пишу программы за еду.
__________________
|