• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 243
  • Last Modified:

TCp Server respond

I have a Component, called TTCPServer, and would simply like to know how I answer a question from a WebBrowser, that connects to my TTCpServer Application at a given port. It (The WebBrowser) peeks, GET /index.html /HTTP 1.0, or something like that, and I would like to know how I respond to this and redirect or refer it to a file on my harddrive, called index.html, so it loads it. By the way this only seems to work in Netscape, (not that it really matters).

Check this out

procedure TForm1.OnData(Socket: TSockets);
   S : String;
With TTCpServer1 Do
   S := Peek(Socket);
    // If everything works as it should, S now //contains perhaps, GET /index.html / HTTP 1.0 and I'd like to know how I respond to this and give it the address, 'C:\index.html' for instance, so it loads it

Hope someone can help me....
1 Solution
klasseAuthor Commented:
Adjusted points to 250
Do you have a TELNET client program?  Or a simple TCP Client program?  If you want to find out what is returned from web servers, just telnet to one:

  C:\> TELNET www.microsoft.com 80

(You might have to enable Local Echo to see what you're typing)

And then type the following to see the web server's headers:
Or to get the whole page including the headers:
GET / HTTP/1.0

It would probably be best to telnet to a real .HTML file instead of just "www.microsoft.com/"  like  "www.server.com/afile.html".


Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now