Download presentation
Presentation is loading. Please wait.
1
Socket Programming Cal Poly Pomona Young CS380
2
IP Address Port Number What is a socket ? Wh
A socket is one endpoint of a two-way communication link between two programs running on the network, which consists of IP Address AND Port Number CS380 Socket Programming
3
What do sockets do? Sockets TCP connection Server Client
allows programs on different machines send data to one another CS380 Socket Programming
4
How to establish connections?
Server Side: Create Server Socket Bind the Server Socket to a specific port Listen for incoming connection requests Accept requests and bind new sockets to different port numbers, then go back to listen Remarks: are reserved (well-known) port which are used only by OS CS380 Socket Programming
5
How to establish connections?
Client Side: Create Socket Connect using IP Address and Port Number of the server process The port number used by client locally is allocated by OS dynamically CS380 Socket Programming
6
How to establish connections?
..... Server Process Client Server machine A Client machine B Ports Connection Request to (A,n) n Server creates Server Socket and listen to port number n Client creates Socket Client connects socket to machine A at port n Server rebind new connections to different ports and continue to listen CS380 Socket Programming
7
How to establish connections?
..... Server Process Client Server machine A Client machine B Ports n TCP connection established!! CS380 Socket Programming
8
Socket in Java Server Side ServerSocket, Socket
ServerSocket ss = new ServerSocket(port); Socket s = ss.accept(); CS380 Socket Programming
9
Socket in Java Client Side: Socket
Socket s = new Socket(hostname,port); CS380 Socket Programming
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.