CN Lab Ports, Sockets
CN Lab Ports, Sockets
CN Lab Ports, Sockets
Port, Sockets
Internet
Server
Local Area Network
PDA
2
Client
Re
qu
es
Server
Re
s
Client machine
Network
ul
Server machine
3
Networking Basics
Applications Layer
User apps
TCP
UDP
Programming Interface:
Sockets
Network Layer
HTTP
FTP
Telnet
Transport Layer
IP
Link Layer
TCP/IP Stack
Standard apps
Application
(http,ftp,telnet,)
Transport
(TCP, UDP,..)
Network
(IP,..)
Link
(device driver,..)
Device drivers
Networking Basics
HTTP
FTP
Telnet
TCP/IP Stack
Application
(http,ftp,telnet,)
Transport
(TCP, UDP,..)
Network
(IP,..)
Link
(device driver,..)
Networking Basics
Clock server
Ping
TCP/IP Stack
Application
(http,ftp,telnet,)
Transport
(TCP, UDP,..)
Network
(IP,..)
Link
(device driver,..)
Understanding Ports
server
P
o
r
t
app
app
app
app
port
port
port
port
TCP or UDP
Data
TCP
Client
Packet
port# data7
Understanding Ports
ftp 21/tcp
telnet 23/tcp
smtp 25/tcp
login 513/tcp
Sockets
Socket Communication
port
server
Connection request
Client
10
Socket Communication
If everything goes well, the server accepts the
connection. Upon acceptance, the server gets a new
socket bounds to a different port. It needs a new socket
(consequently a different port number) so that it can
continue to listen to the original socket for connection
requests while serving the connected client.
port
port
server
Connection
port
Client
11
Java Sockets
Server
ServerSocket(1234)
Output/write stream
Client
Input/read stream
Socket(128.250.25.158, 1234)
It can be host_name like mandroo.cs.mu.oz.au
12