Network Programming • All networked computers have an IP Address

advertisement
Network Programming
• All networked computers have an IP Address
– Unique
– In the form of xxx.xxx.xxx.xxx (255.255.255.255)
– 32 bits = ~4 billion possibilities (IPv4)
• Most computers have multiple network cards
called “interfaces”
– Wireless card
– Ethernet adapter
– VPN
From the cmd
Ports
• Machine can specify one of ~65K ports
– Allows for multiple network connections
– First 1024 are reserved by the OS
• Common ports
–
–
–
–
–
–
21 FTP (File Transfer Protocol)
22 SSH (Secure Shell)
23 Telnet
25 SMTP (Simple Mail Transfer Protocol)
80 HTTP (HyperText Transfer Protocol)
110 POP3 (Post Office Protocol)
** 13 is Time Protocol and 17 is Quote of the Day
DNS
• Domain Name Service
– Translates human-readable into IP Address
– Relieves burden of memorization!
– This is what many applications use
• Example:
– www.google.com
– 74.125.47.106
nslookup
Client/Server
• Servers wait – a LOT
• Client wants some data/service from server
• Process
1.
2.
3.
4.
5.
Client connects to server
Client sends request for info
Server finds the information
Server sends the information
Client/Server disconnect?
“One-shot” Servers
“One-shot” Servers
Gee, I’m lonely
I need a
texture!
“One-shot” Servers
Someone loves
me!
Make a connection
“One-shot” Servers
Let me find that
for you…
GET spriteSheet.png
“One-shot” Servers
Here ya go!
<DATA>
“One-shot” Servers
Gee, I’m lonely
“Broadcast” Servers
A
B
C
“Broadcast” Servers
A
B
C
One thread per client
Here are my
coordinates!
A
B
C
“Broadcast” Servers
“Broadcast” Servers
Hey guys! “A”
has moved
A
“A” is at <375.0, -41.0>
B
C
Summary
•
•
•
•
IP Address
Port
Client/Server relationship
Programming:
– If you can read/write to files, you can read/write
to the network
– Developing “Poor Man’s Web Browser”
– Developing “Poor Man’s Web Server”
Download