Select the true statements about the connection-oriented and connectionless types of communication. (Select two answers.)
1. In the context of TCP/IP networks, the communication side that initiates a connection is called the client, whereas the side that answers the client is called the server.
2. Connectionless communications are usually built on top of TCP.
3. Using walkie-talkies is an example of a connection-oriented communication.
4. A phone call is an example of a connection-oriented communication.
A is true because in the context of TCP/IP networks, the communication side that initiates a connection is called the client, and the side that answers the client is called the server. This is the basis for establishing a connection-oriented communication.
D is true because a phone call is an example of a connection-oriented communication. Like TCP/IP, a phone call establishes a connection between two devices (in this case, two phones) before communication can occur.
A is true because in the context of TCP/IP networks, the communication side that initiates a connection is called the client, and the side that answers the client is called the server. This is the basis for establishing a connection-oriented communication.
D is true because a phone call is an example of a connection-oriented communication. Like TCP/IP, a phone call establishes a connection between two devices (in this case, two phones) before communication can occur.
B is false because connectionless communications are usually built on top of UDP, not TCP. UDP is a connectionless protocol that does not establish a connection before sending data.
C is false because using walkie-talkies is an example of a connectionless communication. Walkie-talkies do not establish a connection before communication begins, and messages are simply broadcasted to all devices within range.
Here is a sample code in Python using thesocketmodule to create a TCP server and client to demonstrate the connection-oriented communication:
Server-side code:
import socket
HOST = '127.0.0.1'
PORT = 8080
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.bind((HOST, PORT))
s.listen()
conn, addr = s.accept()
with conn:
print('Connected by', addr)
while True:
data = conn.recv(1024)
if not data:
break
conn.sendall(data)
Client-side code:
import socket
HOST = '127.0.0.1'
PORT = 8080
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect((HOST, PORT))
s.sendall(b'Hello, world')
data = s.recv(1024)
print('Received', repr(data))
The server listens for incoming connections on port 8080, and when a connection is established, it prints the address of the client that has connected. The server then continuously receives data from the client and sends it back to the client until the connection is closed.
The client establishes a connection with the server and sends the message 'Hello, world' encoded as bytes. It then waits for a response from the server and prints the data it receives.
Elinore
17 days agoLindsey
21 days ago