slackbuilds_ponce/network/nweb/README.client
Dave Woodfall 41b95cf8cb
network/nweb: Added (tiny web server in C).
Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
2021-04-16 17:33:06 +07:00

64 lines
3 KiB
Text
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

client.c
This client.c program is designed to fake being a web browser. It sends the
expected requests to the web server over a network socket connection and
displays the results as text rather than graphically displaying the results. In
the code you will have to change the two lines as below to match your web
server or nweb server.
/* YOU WILL HAVE TO CHANGE THESE TWO LINES TO MATCH YOUR CONFIG / #define PORT
* 8181 /
Port number as an integer - web server default is 80 / #define IP_ADDRESS
"192.168.0.8" / IP Address as a string */
The default is to request the /index.html from the web server. If you want to
request another file then change the GET line as below:
char *command = "GET /index.html HTTP/1.0 \r\n\r\n" ;
To, for example:
char *command = "GET /nigel.jpg HTTP/1.0 \r\n\r\n" ;
Then compile the program with: cc client.c -o client
I save the output in to a file as putting a non-test file like .jpg to the
terminal screen can cause chaos: client >output
Then edit the output file: vi output
In real life, the interaction of web browser and web server can be much more complex.
 1. The web browser can tell the web server about its name, version and capabilities.
 2. The web server can send complex file types line JavaScript or Java programs
or other active components.
 3. They can maintain a longer connection over the socket for efficiency.
 4. Below is an example of my Firefox brower requesting an index.html file. I
have added newline characters to make it readable - it is 1300 bytes long! I
have no idea what most of it is about. You will have to read the The World Wide
Web Consortium (W3C) at http://www.w3.org for all the details.
GET /index.html HTTP/1.1Host: myserver.home.com:80User-Agent: Mozilla/5.0 (W indows;
U; Windows NT 5.1; en-GB; rv:1.9.2.28) Gecko/20120306 Firefox/3.6.28 (.NET CLR
3.5.30729)Ac cept: image/png,image/;q=0.8,/*;q=0.5Accept-Language:
en-gb,en;q=0.5Accept-Encoding: gzip,defla teAccept-Charset: ISO-8859-1,utf-8;
q=0.7,*;q=0.7Keep-Alive: 115Connection: keep-alive**Referer:
http://myserver.uk.home.com:8181/index.html**Cookie:
__utma=101107545.1790272076.1316019590.13289002 55.1328908680.164;
__utmz=101107545.1328566199.157.46.utmcsr=t.co|utmccn=(referral)|utmcmd=referral| u
tmcct=/iTJx4DO1; UnicaNIODID=ZBr8gm79vIG-XKeoGGb; W3SSO_ACCESS=abc.home.com;
ISP=70fdfc95
d93011d783e4de784ea97766-70fdfc95d93011d783e4de784ea97766-f67749a8b899e8ceed7e940b8c4bf189;
Prof ile=2000121913394303111032836125|EN|866|866.BDF|en-GB;
_unam=693fb60-1337f162b72-11770d11-5; WLS intra_USERID=nigel@hotmail.com;
ipcInfo=cc%3Duk%3Blc%3Den%3Bac%3Dall; iwm1p=214617669; bprememberme=nigel@
hotmail.com; EPSPROFILE=EE2355DFE16AE020BE6C62FCB6BF5602;
DWPERM=Xa.2/Xb.Xzso3-U35t8RWKvqBreGaQMgsP_RG
Fl1124oIt-L-OPJIdSautkBN0D4NUp9JLlpUqPqB6CWOo-pgrJwhxNvvSfPAajgetaA2MOYwHfQPXPTRG9zwOMMR57EHQtXhOy5Om
yzanyZthvVClm6uxvbwh0isEQ2Mm_9g2l7NjcA3RJdjuLaB3qlljOmyVuhDjBkgdNEb3PgYcCpbiu1FUzXrhPalhgsbAj7NBkaY88
Yyg/Xc./Xd./Xf./Xg.1696801
I hope this has been instructive, thanks, Nigel Griffiths