Internet Applications & Programming Chapter 3 Internet Applications & Programming © Bobby Hoggard, Department of Computer Science, East Carolina University These slides may not be used or duplicated without permission
Internet Applications The Internet is diverse with services None of the services is part of the Internet structure The Internet provides a common communication medium New services can be created
Two Communication Means Stream Message Connection Oriented 1-to-1 Communication Send Sequence of Bytes Any Length Transfer Widely Used TCP Connectionless Many-to-Many Send Individual Message Limited to 64K Multimedia Applications UDP
Messages (UDP) Connection-less: Very little set-up involved A packet sent represents and entire message as it was originally sent No guarantee that messages sent will be received Messages can be lost Messages can be duplicated Messages can be delivered out of order Faster: no error checking involved Examples of uses include: DNS (domain name lookup) VOIP (voice over IP) Some Games
Streams (TCP) Connection Oriented Guaranteed delivery of packets Two applications must agree on having a connection created Both applications can send and receive After communication is finished, connection is terminated Guaranteed delivery of packets Packets are guaranteed to be in the same order sent Slower: due to the error checking involved Examples of uses include: HTTP (web service) FTP (file transfer) SMTP (email service)
Streams (TCP) Uses a client / server model Client: application which requests a connection to be made Server: application which waits for connection requests
Clients vs. Servers Client Server Starts second Must know the server to which it will connect Initiates contact when needed Can send & receive When finished, the client shuts down Starts first Does not know which client will communicate Passively waits for long periods of time for a connection to be made Can send & receive When finished, waits for another connection
Multiple Clients It is possible (and very common) to have multiple clients operating on one machine All clients can communicate with the same server All clients can communicate with different servers
Multiple Servers It is possible to have multiple servers operating on one machine More efficient use of the machine Makes use of idle time between connections Can be problematic if the servers are busy
Server Identification Servers are identified by a 2-part identification number Computer Identifier Service Identifier IP Address 32-bit number Port Number 16-bit number Domain Name Translator
Server Identification Each service on the server computer has a unique port number When the server starts it registers its port number with the operating system This is what allows the OS to send requests to the correct program when multiple servers are on the same machine Two commonly used port numbers are: port 80 = web browsing port 25 = email service
Server Identification Web Server Client Computer Server Computer 1 Request IP Address Port Number Email Server Request IP Address Port Number Server Computer 2
Client/Server Interaction Start Get Server Name Translate To IP Address Specify Port Number Contact Server Stop Start Register Port # with OS Wait For Client Interact With Client Finished
Concurrent Server Processing Server uses a thread of control for each client Will have a main thread and one thread for each client it is processing The main thread waits for connections and handles the connection set up Once the connection has been made, a client thread is created to continue the communication, while the main thread continues to wait for more requests
Servers Can Be Clients! Web Browser Client Computer Request For ASPX page Web Server Request For Data Database Server HTML page Data CLIENT SERVER CLIENT SERVER