Sending messages using socket
Adam Ruppe
destructionator at gmail.com
Sun Jul 24 10:23:05 PDT 2011
Browsers speak HTTP, which is a higher level protocol than
plain sockets.
If you connect to your app with a simpler program, like nc,
you'll probably see the message.
If you want to serve web pages, consider one of these options:
a) Looking up the HTTP protocol itself. You've gotta send headers
before you send data or the browser won't understand what you are
replying to.
b) Use an existing web server, like Apache, and write your app as
a cgi program
The HTTP headers you need to send on a plain socket look like this:
=====
HTTP/1.0 200 OK
Content-Length: 11
Content-Type: text/html
hello world
=====
instead of just plain "hello world".
More information about the Digitalmars-d-learn
mailing list