2 Application SocketProgramming.pdf


Preview of PDF document 2-application-socketprogramming.pdf

Page 1 2 3 4 5 6 7 8

Text preview


Socket Programming using TCP
Socket: a door between application process and the end-end-transport
protocol (UDP or TCP);
TCP service: reliable transfer of bytes from one process to another.

controlled by
application
developer
controlled by
operating
system

process

process

socket
TCP with
buffers,
variables

socket
TCP with
buffers,
variables

host or
server

internet

controlled by
application
developer
controlled by
operating
system

host or
server
RC – Prof. Paulo Lobato Correia

5

Socket Programming using TCP
Client must contact server:
Server process must first be running;
Server must have created socket (door) to welcome client contacts.
Client contacts server by:
Creating client-local TCP socket;
Specifying IP address, port number of server process;
When client creates socket:




Client TCP establishes connection to server TCP.

When contacted by client, server TCP creates new socket for
communication between server and client:



Allows server to talk with multiple clients;
Source port numbers are used to distinguish clients.

TCP provides reliable, in-order transfer of bytes
(“pipe”) between client and server
RC – Prof. Paulo Lobato Correia

6

3