CPNT 217 Socket Programming Flashcards

(51 cards)

1
Q

What is socket programming?

A

A method for creating network-enabled applications that allow devices to communicate over a network.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does a socket represent?

A

An endpoint of a network connection

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the two types of sockets in socket programming?

A

Client sockets and server sockets.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the role of a client socket?

A

To initiate a connection with a server socket.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the role of a server socket?

A

To listen for incoming connections from client sockets.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the first step in the socket programming procedure?

A

Creating a socket object and specifying the protocol family

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What does binding a socket involve?

A

Associating the socket with a specific IP address and port number.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What happens when a server socket accepts a connection?

A

It creates a new socket object to handle the connection.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What can both client and server sockets do after a connection is established?

A

Send and receive data through the socket.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the final step in the socket programming process?

A

Closing the connection to release resources.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Why are sockets widely used in network programming?

A

They provide reliable, flexible, efficient way for devices to communicate over a network

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is platform independence in socket programming?

A

Sockets can run on most modern operating systems without modification.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What protocols do sockets support?

A

A wide range including TCP/IP, UDP and HTTP

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What type of applications are TCP sockets ideal for?

A

Applications requiring reliable data transfer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What type of applications are UDP sockets ideal for?

A

Applications requiring fast data transfer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the socket module in Python used for?

A

Creating and using sockets for network programming.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is flow control in TCP?

A

Mechanisms to manage the rate of data transmission and avoid network congestion.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is congestion control in TCP?

A

Mechanisms to prevent network congestion during data transmission.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What is the significance of the SOCK_DGRAM parameter in Python?

A

It indicates that a UDP socket is being created.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What is the significance of the SOCK_STREAM parameter in Python?

A

It indicates that a TCP socket is being created.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What does it mean for a protocol to be connectionless?

A

Data can be sent without establishing a dedicated connection first.

22
Q

What are some common applications of socket programming?

A

Chat applications

23
Q

What is the main advantage of using sockets for communication?

A

They provide a robust and versatile programming interface for reliable communication.

24
Q

How do you create a TCP socket in Python?

A

Use the code: tcp_socket = socket.socket(socket.AF_INET)

25
How do you create a UDP socket in Python?
Use the code: udp_socket = socket.socket(socket.AF_INET)
26
What does AF_INET specify when creating a socket?
It specifies the protocol family for IPv4.
27
What does SOCK_STREAM specify when creating a socket?
It specifies that the socket is for TCP.
28
What is the purpose of the bind() method in socket programming?
It binds the socket to a specific IP address and port.
29
What is the default IP address used in the example for the server?
'127.0.0.1'
30
What does the listen() method do in a socket server?
It allows the server to listen for incoming connections.
31
What is the purpose of the recv() method in socket programming?
It is used to receive data from the socket.
32
What does the send() method do in socket programming?
It is used to send data over the socket.
33
What is SSL in the context of socket programming?
SSL (Secure Sockets Layer) is a protocol for secure communication over a network.
34
What are the advantages of using SSL?
Encryption, authentication, integrity
35
What has SSL been superseded by?
Transport Layer Security (TLS).
36
What is the main feature of WebSockets?
It enables bidirectional communication between a client and a server.
37
How does WebSockets differ from regular HTTP connections?
WebSockets allow ongoing real time communication between client and server
38
What should you do to handle errors in socket programming?
Use try-except blocks to catch and handle exceptions.
39
Why is it important to close sockets properly?
To prevent resource leaks and ensure the socket is released for other applications.
40
What are some security risks in socket programming?
Buffer overflows, injection attacks, and man-in-the-middle attacks
41
What is a best practice for managing sockets in Python?
Use context managers to handle the opening and closing of sockets.
42
What is the purpose of the print statements in debugging socket programs?
To output debug information at strategic points in the code.
43
What is the role of the accept() method in a socket server?
It accepts a connection from a client.
44
What is the maximum amount of data that can be received in the example?
1024 bytes.
45
What is one way to analyze network traffic when debugging?
Use tools like Wireshark.
46
What is the significance of using TLS/SSL in socket programming?
To encrypt sensitive data and avoid security risks.
47
What is the main function of the socket module in Python?
To create and manage sockets for network communication.
48
What happens if you do not handle errors in socket programming?
It can lead to crashes and unexpected behavior of the program.
49
What is the first step in setting up a socket server?
Create a socket object using the socket() method.
50
What is the output of the server when a client connects?
'Client connected:' followed by the client's address.
51
What should you do after sending data back to the client?
Close the client socket using client_socket.close().