You are on page 1of 22

Interpersonal Communications

My experience on campus Dr Knutson driving Experiment? There is another responsibility correlated and even coexistent with agency, which is too infrequently emphasized, and that is the effect not only of a persons actions, but also of his thoughts. Man radiates what he is, and that radiation affects to a greater or lesser degree every person who comes within that radiation David O. McKay (Free Agency The Gift Divine, Improvement Era, Feb 1962, 87) Thoughts mold your features. Thoughts lift your soul hevenward or drag you toward hell As nothing reveals character like the company we like and keep, so nothing foretells futurity like the thoughts over which we brood To have the approval of your conscience when you are alone with your thoughts is like being in the company of true and loving friends. To merit your own self-respect gives strength to character. Conscience is the link that binds your soul to the spirit of God David O. McKay (Those Sculptors Called Thoughts and Ideals, Improvement Era, July 1960, 495).

Applications

Daemons

Program that listens on a particular port and accepts connections for a protocol Each protocol listens on a different port A server is then created to interact with the client
daemon

Server

Client

Example Application: Remote Login w/ TELNET


Provides interactive access to computer from a remote site Text-oriented interface User invokes client specifies remote computer Client forms TCP connection to server passes keystrokes over connection displays output on screen
Defined in RFC 854

Example Application: File Transfer Protocol (FTP)


Complete file copy Uses TCP Supports binary or text file transfers Large set of commands Until 1995, it was the major source of packets on the Internet Defined in RFC 959

FTP Illustrated

Example Application: World Wide Web (WWW)

Web pages

can contain text, images, imbedded objects and links standard authoring format is HTML links use URL tags transferred using HTTP

See http://www.w3c.org for all the details

HyperText Markup Language


Document is free-format Embedded tags give display format Tags (often appear in pairs)

Paragraph <P> and </P> Line break <BR> Headings <H1>, <H2> <IMG src=jtk.jpg border=0> <A href=http://www.depaul.edu>DePaul</A>

Uniform Resource Locator (URL)


Symbolic representation Embedded in HTML document Browser


hides text of link from user associates link with item on page makes items selectable

URLs Illustrated
(http :// www.byu.edu /index.html)

HyperText Transfer Protocol (HTTP)


Web server makes web pages available Server uses port 80 by default Web client (browser) requests pages Creates a TCP connection to server HTTP sits on top of TCP HTTP v1.1 defined in RFC 2068

major enhancement over v1.0: single TCP connection for multiple HTTP requests

HTTP Lab

Write a HTTP Daemon (web server) Connect with netscape to your server Retreive gif, txt, html files Run CGI scripts

HTTP Protocol

Web browser receives a url

http://hostname:port/pathname

Web browser connects to hostname and sends pathname in a HTTP request over to socket

GET /pathname HTTP/1.0

Web server responds with contents of file or error page

Example
telnet students.cs.byu.edu 80 GET /foo.html HTTP/0.9 404 Server: Apache/1.3.3 Ben-SSL/1.29 (Unix) PHP/3.0.7 Content-type: text/html <HEAD><TITLE>404</TITLE></HEAD> <BODY bgcolor=FFFFFF><H1><img alt="" src=/images/icon.gif>404</H1> The requested URL:<code>/foo.html</code> was not found on this server.

Response
HTTP/1.0 200 OK Attribute: value Attribute: value Attribute: value ... file data ...
TIP: use \r\n on the end of every line. Different browsers are picky about this and there are no real error messages if the browser doesnt like your format write(sock, "HTTP/1.0 200 OK\r\n", strlen ("HTTP/1.0 200 OK\r\n"));

Details

Status
200 OK means that the request was completed successfully 404 is an error that will usually be followed by html describing the problem

The attributes tell the browser how to display the content


Content-Type:<CONTENT TYPE><CRLF> Text: text/plain Html: text/html GIF: image/gif JPEG: image/jpeg Content-Length:<file-length in bytes><CRLF> Some browsers ignore this and figure it out on their own.

Example
http://tape.cs.byu.edu:1234/bungo.html
The browser opens a socket connection to tape on port 1234. Your code should be listening on this port. The browser will then send the following request to your code. GET /bungo.html
Followed by a bunch of information about the version and capabilities of the browser (this is how Amazon.com can charge you different prices depending on where you connect from). You should then respond with the contents of the file bungo.html if you can find the file

Details

If the file exists, send it immediately after the Content-type attribute If it doesnt exist, send html with an error message and the 404 status If it is a directory

If there is a index.html file, send it Otherwise, send a listing of the directory system(ls pathname > file); then send file fd=popen (ls pathname); then read from fd

CGI
http://cheese.cs.byu.edu:1236/test6.cgi?teststring Is converted to GET <path>/<cgi-script>?query=<query text>+<param>|+<param>|+... GET /test6.cgi?query=teststring Your server should put the query string into an environment variable called QUERY_STRING, set up the environment variables REQUEST_METHOD and SERVER_PORT Execute the command (perl script) Capture the output and send it back on the socket

Code Sample
main() { char *cmd = "/usr/bin/ls *.c"; char buf[BUFSIZ]; FILE *ptr;
if ((ptr = popen(cmd, "r")) != NULL) while (fgets(buf, BUFSIZ, ptr) != NULL) (void) printf("%s", buf); return 0; }

Environment Variables
/*Create the environmental variables*/ sprintf(query_dest,"QUERY_STRING=%s",query); sprintf(content,"CONTENT_LENGTH=%s",length); sprintf(shell_cmd,"%s > %s",filename,handle); putenv("REQUEST_METHOD=GET"); putenv(content); putenv(query_dest);

Passoff

Passoff Level Behavior Minimal Passoff You can send the basic html, txt, gif, jpg files Basic CGI You can run test5.cgi Perfect behavior You can also pass environment variables to test6.cgi and list the contents of a directory if specified

Points 4 Points 3 Points 3 Points

You might also like