We help IT Professionals succeed at work.

need information...(easy)

krydea
krydea asked
on
hello guy's,
i whan't to start real delphi programming so not the "what you see is what you get editor"  of borland.
but when you start a console app make it a windows app. i found a example like this:
www24.brinkster.com/2krydea/example.drp
i seard for tutorails but i could only find the "what you see is what you get editor" tutoails.
CreateWindow ). but how does it work with sockets etc..

every information is welkom. plz help.
Carlos smith
Comment
Watch Question

Don't quite follow you problem here, seems to me that you want to use delphi, but without using the IDE?

The IDE is actually quite good (ducks the flames). The usage of TForms and descendants is optional, although is does save alot of time creating windows and stuff.  What is the point of re-inventing the wheel for every application that you write.

You can get component's to do practically anything that you want. And even if the component does not exist there it nothing stopping you from creating one.

AS for Sockets, take a look and the Indy components there free and you can get them from

http://www.nevrona.com/indy

Colin Dawson

Author

Commented:
yea true,
but i whant to learn how the wheel is made.:p
so you don't even know tutorails about it?
plz help.

Author

Commented:
<- i got socket componets in my delphi 5(TClientSocket,TServerSocket). but how to use it -> with out the "what you see is what you get editor.".
you can't say you can programme delphi if you don't know this!!!!!...............you can say you can programme borland delphi... and for myself i whant to change that..:p
ok, so you want to create objects programatically. Fine, here an example.

Procedure CreateAForm;
Var
  MyForm : TForm;
Begin
  MyForm := TForm.Create( Application ); //Application is the owner so that delphi destorys the form when the application is terminated.
  Try //Good error capturing practise
    MyForm.Caption := 'This is my Form';
    MyForm.ShowModal;
  Finally
    FreeAndNil( MyForm ); //Delphi 5 and above.
  End;
End;

The routine above will create a form then when you close the form destroy the hidden object.

You'll find it easier to create a basic form using the IDE, turn off the autocreate then modify the above code to create it.

you can also create other objects on-the-fly like TEdits and such:-)

Procedure CreateEdit( Parent : TForm );
Var
  MyEdit : TEdit;
Begin
  MyEdit := TEdit.Create( Parent ); //Create the object
  MyEdit.ParentWindow := Parent.Handle; //make sure that it's owned correctly.
  MyEdit.Visible := True;
  MyEdit.Top := 10;
  MyEdit.Left := 10;
  MyEdit.Text := 'There you go';

  //At this point we loose the refence to the Editbox, so you'll need to make the variable more globalised.
End;


I hope this is what you're getting at.

Colin D.
I tried using the TClientSocket and TServerSocket, but I'm trying to save you from alot of problems, by saying... don't bother with them, use the indy components they are WAY better and are even shipped as part of Delphi 6!

Colin Dawson.

Commented:
Even better use the ICS suite of TCP/IP components.
Their really cool; I've used 'em in regular GUI apps,
in multi-threaded apps (not WYSIWYG) and they haven't
let me down - except for proxy support. But I think that's
been addressed.
http://www.rtfm.be/fpiette

Author

Commented:
that whas not what i asked!

Author

Commented:
k,
umm.... i have to use pascal to do the sockets.
so you don't got a reference or a tutorail for this stuff?
how is it called to programme delphi without the borland compiler?
I think I see what you are getting at now.

Welcome to the world of Delphi, think of it as Visual Pascal.

Basically Delphi is like Turbo Pascal 8, the WYSIWYG approach is the way that programs are written these days.  But it's got another name RAD (Rapid Application Development).

Delphi is Borlands product, it's not possible to "programme delphi without the borland compiler".  If you desire you can use delphi, to create a program without a form, then use windows API calls to generate your program.

Real Delphi Programers (like myself) simply cannot be bothered to do that everytime.  In fact the whole Ethos of delphi is geared toward code re-use.  We develop objects that will perform the task that we desire then whenever possible re-use the object as many times as possible.  We even go to the lengths of using 3rd party components, most of which are free, but there are some really good ones that you have to pay for.

As for programming sockets using only code, check out the WINSOCK API. It's supplied by microsoft and tells you exactly how to program using sockets.

Author

Commented:
umm do you got some urls for me?
Here's a few to get you started.


http://www.nevrona.com/indy - Really good TCP socket components
http://www.torry.net/ - you'll find just about eveything else here
http://www.delphifreestuff.com - Brad Stowers, some good stuff in here
http://delphi.icm.edu.pl/ - Delphi super page if torry don't got it, maybe it's here

There are others on the net, but these are the best that I've seen... so far.

Author

Commented:
hello
1.http://www.nevrona.com/indy - Really good TCP socket components
>>i don't whant componets
http://www.torry.net/ - you'll find just about eveything else here
>> that suck i know it.
http://www.delphifreestuff.com - Brad Stowers, some good stuff in here
http://delphi.icm.edu.pl/ - Delphi super page if torry don't got it, maybe it's here
i will have a look.

btw: i'm asking for tutorails for turbo pascal or the visual pascal and the sockets for that......

Author

Commented:
i looked and can't find anny tut or reference...:(
You won't find any.  Turbo Pascal is obsolete and I was referring to Delphi BEING visual pascal.  You are better looking for a pascal tutorial.  You should also consider looking for books, here's a couple of good ones.

Delphi 5 Developers Guide
Mastering Delphi 5

A little older but, still worth looking at is

Delphi 3 Client/Server Developers Guide.

This is more of a more rounded introduction to producing software (focusing on databases) using delphi.

It's goes into stuff like making a help file, how to use the IDE. And more importantly for you... WHY!

Author

Commented:
i know enuf delphi!?
but i whant the beginning so i have to seard for pascal or visual pascal?

Author

Commented:
umm i know why its easy but i whant just for now not the edi..
k?
plz help seards voor the non ide delphi stuff.. plz.
hmmm, looks like you really do want to do this the hard way.

don't bother searching for pascal at all.  Instead search for stuff to do with the WIN32 API.

It's a set of procedure calls that microsoft released in order to allow programmers to develop their own applications that use windows.  The best source of information for this is

http://msdn.microsoft.com

Problem is though, there's no tutorial as such. It's a reference guide to all the calls that you can do within windows.

For information: the delphi VCL is a set of wrappers that make using the WIN32 API easy to use.  The WIN32 API was renamed to the Platform SDK about 18 months ago.

If this is not what you are looking for, then I don't think I can help anymore.

Author

Commented:
:s not even to help me seards: i hate msdn to mutch crap:s

Author

Commented:
k
maybe you can help me with a pascal tutorail about winsco or socket programming?
You're using Delphi, it creates programs compatible with windows. Windows uses the WIN32 API a.k.a the Platform SDK.
The Platform SDK is produced by Mircosoft.
the best place to find out about the Platform SDK is from Microsoft.
Microsoft published the MSDN website for just that purpose.

MSDN is the most up-to-date place to get info, end of story.

Author

Commented:
dohh i know that,
i can't find it seards for you self you only find crap!!!!!

Author

Commented:
thanx for your help... but i still doesn't have a answer.
so i'm gana ask it in the pascal section!

Author

Commented:
not the place to ask!
I think you do have and answer, it's just not an answer that you like.

Author

Commented:

Author

Commented:
nope i don't got a answer!!
did i got a referece or a tutorail about whant i ask no
only about begin delphi programmeing dohh i know that al already i whant to know befor the wheel and then you give me msdn and that site suck's if you can find something there but no crap give it!

Author

Commented:
nope i don't got a answer!!
did i got a referece or a tutorail about whant i ask no
only about begin delphi programmeing dohh i know that already i whant to know befor the wheel and then you give me msdn and that site suck's if you can find something there but no crap give it!

Author

Commented:
no answer just comment on may work:s
Krydea, yup i have tried to get at the same information many times myself, the best i got was a unit (which my friend made) but he never turned it into a console program like i wanted :(

um, uses Winsock;

your program goes here..... check out this (this a Component).

unit DZSocket;

interface

uses
  Windows, Messages, SysUtils, Classes, WinSock, Forms;

const
  WM_WSAASYNC = WM_USER + $1;

  CONNECTSTRING = 'CONNECT %s:%d HTTP/1.0'#$0D#$0A'Host: %s'#$0D#$0A#$0D#$0A;

type
  TDZSocketErrorEvent = procedure (errormessage: String) of object;

  TDZSocketConnectEvent = procedure (IP: String; Port: Integer) of object;
  TDZSocketDisconnectEvent = procedure of object;
  TDZSocketReadEvent = procedure (Data: String) of object;

  TDZSocket = class(TComponent)
  private
    { Private declarations }
    FHandle: HWnd;
    FSocket: TSocket;
    FWSAData: TWSAData;
    FVersionRequested: Word;
    FError: Integer;
    FSockAddrIn: TSockAddrIn;
    FHostEnt: PHostEnt;
    FHost, FProxyHost: String;
    FPort, FProxyPort: Integer;
    FConnected, FProxyConnected, FUseHTTPProxy: Boolean;
    FOnError: TDZSocketErrorEvent;
    FOnConnect: TDZSocketConnectEvent;
    FOnDisconnect: TDZSocketDisconnectEvent;
    FOnRead: TDZSocketReadEvent;
    procedure WSASelectHandler(var msg: TMessage); message WM_WSAASYNC;
    procedure DZWndProc(var Message: TMessage);
    procedure RaiseError(ErrorMessage: String);
    function ReadSocket(var Buffer: String): Integer;
  protected
    { Protected declarations }
  public
    {Public declarations }
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
    procedure Connect;
    procedure Disconnect;
    procedure SendText(const Text: String);
    function HostToIP(Host: String): String;
    function IPToHost(IP: String): String;
  published
    { Published declarations }
    property Host: String read FHost write FHost;
    property ProxyHost: String read FProxyHost write FProxyHost;
    property Port: Integer read FPort write FPort;
    property ProxyPort: Integer read FProxyPort write FProxyPort;
    property UseHTTPProxy: Boolean read FUseHTTPProxy write FUseHTTPProxy;
    property OnError: TDZSocketErrorEvent read FOnError write FOnError;
    property OnConnect: TDZSocketConnectEvent read FOnConnect write FOnConnect;
    property OnDisconnect: TDZSocketDisconnectEvent read FonDisconnect write FOnDisconnect;
    property OnRead: TDZSocketReadEvent read FOnRead write FOnRead;
  end;

procedure Register;

implementation

constructor TDZSocket.Create(AOwner: TComponent);
begin
  Inherited Create(AOwner);
  FHandle:=AllocateHwnd(DZWndProc);
  FVersionRequested:=MAKEWORD(1,1);
  FError:=WSAStartup(FVersionRequested,FWSAData);
  if error <> 0 then
    RaiseError('Unable to find a useable sockets implementation');
  if FWSAData.wVersion <> FVersionRequested then
  begin
    RaiseError('Unable to find a useable sockets version');
    WSACleanup;
  end;
  FSockAddrIn.sin_family:=AF_INET;
  FSocket:=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
  if FSocket = INVALID_SOCKET then
    RaiseError('Unable to create socket');
  if WSAAsyncSelect(FSocket,FHandle,WM_WSAASYNC,FD_CONNECT or FD_READ or FD_CLOSE) = SOCKET_ERROR then
    RaiseError('WSAAsyncSelect Error! :(');
end;

destructor TDZSocket.Destroy;
begin
  if FConnected or FProxyConnected then
    Disconnect;
  WSACleanup;
  DeallocateHWnd(FHandle);
  Inherited Destroy;
end;

procedure TDZSocket.DZWndProc(var Message: TMessage);
begin
  Dispatch(Message);
end;

procedure TDZSocket.WSASelectHandler(var msg: TMessage);
var
  temp, temp2: String;
begin
  case msg.LParam of
    FD_CONNECT: begin
                  if FUseHTTPProxy then
                  begin
                    FProxyConnected:=True;
                    SendText(Format(CONNECTSTRING,[FHost,FPort,FHost]));
                  end
                  else
                  begin
                    FConnected:=True;
                    if assigned(OnConnect) then
                      OnConnect(FHost, FPort);
                  end;
                end;
    FD_READ:  begin
                temp:='';
                temp2:='';
                SetLength(temp2,4096);
                while ReadSocket(temp2) <> 0 do
                  temp:=temp+temp2;
                if FUseHTTPProxy and (LowerCase(temp) = LowerCase(LowerCase('HTTP/1.0 200 Connection established'#$0D#$0A#$0D#$0A))) then
                begin
                  FConnected:=True;
                  if assigned(OnConnect) then
                    OnConnect(FHost, FPort);
                end
                else
                  if Length(Trim(temp)) > 0 then
                    if assigned(OnRead) then
                      OnRead(temp);
              end;
    FD_CLOSE: begin
                SetLength(temp,4096);
                while ReadSocket(temp) <> 0 do
                  SetLength(temp,4096);
                if assigned(OnDisconnect) then
                  OnDisconnect;
              end;
  end;
end;

procedure TDZSocket.Connect;
begin
  if not FConnected then
  begin
    if FUseHTTPProxy then
    begin
      FHost:=HostToIP(FHost);
      FSockAddrIn.sin_port:=htons(FProxyPort);
      FSockAddrIn.sin_addr.S_addr:=inet_addr(PChar(HostToIP(FProxyHost)));
    end
    else
    begin
      FSockAddrIn.sin_port:=htons(FPort);
      FSockAddrIn.sin_addr.S_addr:=inet_addr(PChar(HostToIP(FHost)));
    end;
    winsock.connect(FSocket,FSockAddrIn,SizeOf(FSockAddrIn));
  end;
end;

procedure TDZSocket.Disconnect;
begin
  if FConnected or FProxyConnected then
  begin
    winsock.shutdown(FSocket,2);
    FConnected:=False;;
    if assigned(OnDisconnect) then
      OnDisconnect;
  end;
end;

procedure TDZSocket.SendText(const Text: String);
begin
  if FConnected or FProxyConnected then
    if send(FSocket,pointer(Text)^,Length(Text),0) <> Length(text) then
      RaiseError('Unable to send data');
end;

function TDZSocket.HostToIP(Host: String): String;
var
  temp: Integer;
  addr: PChar;
begin
  Result:='';
  if Host <> '' then
  begin
    temp:=inet_addr(PChar(Host));
    if temp = -1 then
    begin
      FHostEnt:=gethostbyname(PChar(Host));
      if Assigned(FHostEnt) then
      begin
        addr:=FHostEnt^.h_addr_list^;
        if Assigned(addr) then
          Result:=Format('%d.%d.%d.%d',[byte(addr[0]),byte(addr[1]),byte(addr[2]),byte(addr[3])]);
      end;
    end;
  end;
end;

function TDZSocket.IPToHost(IP: String): String;
var
  temp: Integer;
  host: PChar;
begin
  Result:='';
  if IP <> '' then
  begin
    temp:=inet_addr(PChar(IP));
    if temp <> -1 then
    begin
      FHostEnt:=gethostbyaddr(PChar(IP),Length(IP),AF_INET);
      if Assigned(FHostEnt) then
      begin
        host:=FHostEnt.h_aliases^;
        if Assigned(host) then
          Result:=StrPas(host)
        else
          Result:='OH ****!'; //I figure it does not work :D
      end;
    end;
  end;
end;

procedure TDZSocket.RaiseError(ErrorMessage: String);
begin
  if assigned(OnError) then
    OnError(ErrorMessage);
end;

function TDZSocket.ReadSocket(var Buffer: String): Integer;
begin
  Result:=-1;
  if ioctlsocket(FSocket,FIONREAD,Result) = 0 then
  begin
    SetLength(Buffer,Result);
    winsock.recv(FSocket,pointer(Buffer)^,Result,0);
  end;
end;

procedure Register;
begin
  RegisterComponents('TDZ', [TDZSocket]);
end;

end.

going by the fact that nobody understood that you are writing a CONSOLE (little dos window people!!!!) and NOT a windows program that you can stick components onto!!!! forget the IDE just imagine using notepad people...

if you understand that above you should be able to translate it into a Console program - wish you the best of luck, if you do manage to make use of it, could you email me the program? (i simply want to read data from a webpage) just the basics? :)
Thanks -


Craig C.

Author

Commented:
cool, yeah i got the same problem but don't you know some notpad pepole?

Author

Commented:
no help..
Craig, just a quick warning. You're probably going to get flamed by krydea for that.  Here's the reason why.....


the TDZSocket is a descendant of TComponent. The TComponent is part of the VCL, and therefore part of 'the "what you see is what you get editor"  of borland.' Therefore, you cannot be 'real delphi programming'. It doesn't tell you 'how the wheel is made' as it uses the Winsock unit, which is also a part of the VCL, the Winsock is a Borland produced wrapper for the Winsock DLL that ships with Internet Explorer and many versions of windows. Also, it's not a 'referece or a tutorail' so you won't get the points.


Kydea, if you're really serious about learning how delphi works from the inside, then maybe you should purchase a couple of books on the subject.  Here's couple that I've found useful over the years


Mastering Deplhi 6
The WIN32 API bible
The Delphi 6 Developers Guide
Developing Custom Components

Of course, you do realise that some of the VCL is infact written in Assembler, so you should really learm TASM as well.

Author

Commented:
oke i can't give you point's for this less info..do i?
krydea:

Just a friendly reminder to return to this open question.

thanks!
amp
community support moderator
Ok then - after long suffering i got my hands on some Console (not component but real console source code)

program console;
{$APPTYPE CONSOLE}
uses
  SysUtils, Winsock, Windows;

const
  AppName = 'API Winsock';
  APPWIDTH = 630;
  APPHEIGHT = 470;
  WM_USER = $0400;
  WM_WSAASYNC = WM_USER + $0001;
  WM_CLOSE    = $0010;
  WM_DESTROY  = $0002;


var
  WndClass: TWndClass;
  MainForm: HWND;
  WebpageDisplay, WebpageAddress, WebpageName: HWND;
  GetPageButton: HWND;
  WDLabel, WALabel, WPLabel: HWND;
  FontsList: array of HFONT;
  HAppInstance, RichEditDLLHandle: Integer;
  Left, Top, Width, Height, NumFonts: Integer;
  FSocket: TSocket;
  FSockAddrIn: TSockAddrIn;
  SockVersion: Word;
  WSData: WSAData;
  FGetPage, FAddress, FWebPageData, FWebPageTemp: string;
  FWSAStarted: Boolean;
  Msg: TMsg;
  Fn: Integer;

procedure StartupAndCreateSocket;
begin
  SockVersion := MAKEWORD(1,1);
  Writeln('Working Step 1...');
  if Winsock.WSAStartup(SockVersion, WSData) <> 0 then
  begin
  // Writeln('Invalid Winsock Implementation. Terminating');
  //  SendMessage(HAppInstance, WM_CLOSE, 0, 0);
   Writeln('Error Invalid Winsock Implementation. Terminating ');
  end;

  if WSData.wVersion <> SockVersion then
  begin
    Writeln('Invalid Winsock Version. Terminating');
    SendMessage(HAppInstance, WM_CLOSE, 0, 0);
  end;

  FWSAStarted := True;
  FSocket := Winsock.Socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);

  if FSocket = Winsock.INVALID_SOCKET then
  begin
    Writeln('Unable to create socket. Terminating');
    SendMessage(HAppInstance, WM_CLOSE, 0, 0);
  end;

  FSockAddrIn.sin_family:=AF_INET;
  WSAAsyncSelect(FSocket, MainForm, WM_WSAASYNC,    FD_CONNECT or FD_READ or FD_CLOSE);
end;

function HostToIP(Host: string): string;
var
  HostEnt: Winsock.PHostEnt;
  Addr: PChar;
  Temp: string;
begin
  Result:='';
  if Host <> '' then
  begin
    if Winsock.inet_addr(PChar(Host)) = -1 then
    begin
      HostEnt := Winsock.gethostbyname(PChar(Host));
      if Assigned(HostEnt) then
      begin
        Addr := HostEnt^.h_addr_list^;
        if Assigned(Addr) then
        begin
          Str(byte(addr[0]), Temp);
          Result := Temp + '.';
          Str(byte(addr[1]), Temp);
          Result := Result + Temp + '.';
          Str(byte(addr[2]), Temp);
          Result := Result + Temp + '.';
          Str(byte(addr[3]), Temp);
          Result := Result + Temp;
        end;
      end;
    end;
  end;
end;


procedure ShutdownSocket;
begin
  Winsock.WSACleanup;
end;


procedure ConnectSocket;
begin
  FSockAddrIn.sin_port:=htons(80);
  FSockAddrIn.sin_addr.S_addr:=inet_addr(PChar(HostToIP(FAddress)));
  Winsock.connect(FSocket, FSockAddrIn, SizeOf(FSockAddrIn));
end;

procedure CloseSocket;
begin
  Winsock.shutdown(FSocket, 2);
end;

procedure GetPage;
var
  GetText: string;
begin
  GetText := 'GET ' + FGetPage + ' HTTP/1.0'#$0D#$0A'Host: ' +
    HostToIP(FAddress) + #$0D#$0A#$0D#$0A;
  Writeln('Sending: ' + GetText);
  Winsock.send(FSocket, Pointer(GetText)^, Length(GetText), 0);
end;

procedure RequestWebpage;
begin
  if not FWSAStarted then
    StartupAndCreateSocket;
  ConnectSocket;
end;

function ReadSocket(var Buffer: String): Integer;
begin
  Result := -1;
  if Winsock.ioctlsocket(FSocket, FIONREAD, Result) = 0 then
  begin
    SetLength(Buffer, Result);
    Winsock.recv(FSocket, pointer(Buffer)^, Result, 0);
 //   Writeln(Buffer);
  end;
end;


function WindowProc(hwnd: HWND; uMsg: UINT; wParam: WPARAM; lParam: LPARAM):
  LRESULT; stdcall;
begin
  Result := 1;
  case uMsg of
    WM_DESTROY:
    begin
      PostQuitMessage(0);
      Result := 0;
    end;


    WM_WSAASYNC:
    begin
      case lParam of
        FD_CONNECT:
        begin
          GetPage;
          Result := 0;
        end;

FD_READ:
 begin
    Result := 0;
    SetLength(FWebPageTemp, 0);
    FillChar(FWebPageTemp, 0, 0);
   while ReadSocket(FWebPageTemp) <> 0 do
     begin
       FWebPageData := FWebPageData + FWebPageTemp;
        FillChar(FWebPageTemp, 0, 0);
         Writeln(FwebPageTemp);
         end;
       end;

        FD_CLOSE:
        begin
          while ReadSocket(FWebPageTemp) <> 0 do
          begin
            FWebPageData := FWebPageData + FWebPageTemp;
            FillChar(FWebPageTemp, 0, 0);
            Writeln(FwebPageTemp);
          end;
//          SendMessage(WebpageDisplay, WM_SETTEXT, 0, Integer(PChar(FWebPageData)));
        end;
      end;
    end;
  else
    Result := DefWindowProc(hwnd, uMsg, wParam, lParam);
  end;
end;

begin

 HAppInstance := HInstance;

  // Set up window class
  with WndClass do begin
    Style := CS_HREDRAW or CS_VREDRAW;
    lpfnWndProc := @WindowProc; // See function above
    cbClsExtra := 0; // no extra class memory
    cbWndExtra := 0; // no extra window memory
    hInstance := HAppInstance; // application instance
    hIcon := 0; // use default icon
    hCursor := LoadCursor(0, IDC_ARROW); // use arrow cursor
    hbrBackground := COLOR_BACKGROUND; // standard window colour
    lpszMenuName := nil; // no menu resource
    lpszClassName := 'APIForm'; // Name for the window
  end; // with WndClass

  Windows.RegisterClass(WndClass); // Don't use Delphi's version of RegisterClass

  // Create the window
  MainForm := CreateWindow('APIForm', PChar(AppName),
    WS_OVERLAPPED or WS_SYSMENU or WS_MINIMIZEBOX or WS_CLIPCHILDREN,
    0, 0, 0, 0, 0, 0, HInstance, nil);

  FWSAStarted := False;

  // Create Controls
//  CreateControls;
  // Create Buttons
//  CreateButtons;

  // Show the main form maximized
  SetWindowPos(MainForm, HWND_TOP,
    (GetSystemMetrics(SM_CXSCREEN) - APPWIDTH) div 2,
    (GetSystemMetrics(SM_CYSCREEN) - APPHEIGHT) div 2,
    APPWIDTH, APPHEIGHT, SWP_SHOWWINDOW);

           
   FWSAStarted := False;

  // StartupAndCreateSocket;
// ConnectSocket;
  Faddress:='www.geocities.com';
  FgetPage:='';
//  ConnectSocket;
  RequestWebPage;
  //GetPage;
  while GetMessage(Msg, 0, 0, 0) <> False do begin
    TranslateMessage(Msg);
    DispatchMessage(Msg);
  end;

  // Clean up code...
  if FWSAStarted then
    ShutdownSocket;


{//FGetPage, FAddress, FWebPageData, FWebPageTemp: string;
 StartupAndCreateSocket;
 //ConnectSocket;
  Faddress:='www.geocities.com';
  FgetPage:='/cjdelphi/ymsgproto.txt';
  RequestWebPage;
  GetPage;
   while ReadSocket(FWebPageTemp) <> 0 do
    begin
      FWebPageData := FWebPageData + FWebPageTemp;
      FillChar(FWebPageTemp, 4096, 0);
      Writeln(FwebPageTemp);
    end;}


end.


//ok still not working 100% but it's reading succesfully from the website :P




 Craig C.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.