Introduction to Network Programming: socket variables
Sockets inside a computer program: socket
variable
Recall:
A socket
is an end-point of communication
Network application program
can send and receive messages
thorugh a socket
Socket variables: representing a
socket inside a
program
Socket variable =
a variable used in a
computer program
that represents/identifies a
socket
Implementation in UNIX:
A socket variable is
just an integer variable
The value
of the socket (integer) variable
is used to
identify an
entry
in the communication ports
(= a data structure)inside the (UNIX) Operating System
(If you had
taken CS450:
a socket is
like a UNIX file descriptor)
Don't worry if you had not taken CS450; you can understand this material
without it.
Operations on a socket
Operations on a socket:
You can perform a write operation
on a
socket (variable)
writing some
data
to a
socket (variable) will
transmit
the data in a
message
You can perform a read operation
on a socket (variable)
reading
a socket (variable) will
receive
a message
(that was transmitted by
some network program)
If there is no message
in the
receive buffer,
the read operation
will block
until a message is
received