CS 4504 Lecture Notes - Lecture 8: Network Socket, Connectionless Communication, Computer Network Programming

28 views2 pages
28 Sep 2016
School
Course
1
Chapter 4
The Socket API
Instructor Dr. P. Bobbie
Lecture Notes #8
Chapter 4
The Datagram Socket API
The socket API is an Interprocessing Communication (IPC) programming interface originally
provided as part of the Berkeley UNIX operating system. This method was implemented in all
modern operating systems, including Sun Solaris and Windows systems.
A socket API provides a programing construct termed a socket.
A process wishing to communicate with another process must create an instance or instantiate
such a construct. Then the two processes issue operations provided by the API to send and
receive data.
A socket programming construct can make use of either the UDP or TCP protocols.
Sockets that use UDP for transport are known as datagram sockets while sockets that
use TCP are named stream sockets.
Datagram – data packet that is transported.
UDP allows a packet to be transported using connectionless communication.
TCP is connection-oriented and transports a stream of data over a logical connection
established between the sender and the receiver.
The connectionless Datagram Socket
Datagram sockets can support both connectionless and connection-oriented communication at
the application layer because the socket API can create and maintain logical connections for
datagrams exchange between two processes.
In Java, two classes are provided for datagram socket API:
The DatagramSocket class for sockets.
The DatagramPacket classs for the datagram exchange
A process wishing to send or receive data using this API must instantiate a DatagramSocket
object. Each socket is bound to a UDP port of the machine that is local to the process.
To send a datagram to another process, a process must create an object that represents the
datagram itself. This object can be created by instantiating a DatagramPacket that carries:
A reference to a byte array that contains the payload data
The destination address (host ID, port number)
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows half of the first page of the document.
Unlock all 2 pages and 3 million more documents.

Already have an account? Log in

Get OneClass Notes+

Unlimited access to class notes and textbook notes.

YearlyBest Value
75% OFF
$8 USD/m
Monthly
$30 USD/m
You will be charged $96 USD upfront and auto renewed at the end of each cycle. You may cancel anytime under Payment Settings. For more information, see our Terms and Privacy.
Payments are encrypted using 256-bit SSL. Powered by Stripe.