2 - Communication and Sockets Flashcards

(15 cards)

1
Q

What is unicast and multicast?

A

Unicast - message to 1 receiver
Multicast - message to 1+ receiver

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

Write down the flow diagram of sockets

A

Create socket (CS)
bind to socket (S)
connect to server (C)
listen on socket (S)
accept connection (S)
send/receive loop (CS)

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

What happens when you fetch a webpage on the socket level?

A

1) Open socket to port 80 on a server
2) Send it an HTTP request
3) Wait for response
4) Server closes connection

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

What encoding do sockets send?

A

Binary (used instead of text when bandwidth is limited, or battery life needs to be saved)

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

What are things in binary that we can’t encode (at least for free) and how do we fix it?

A

Circular linked list, file-like objects (socket/etc)

To fix, have an “encode” function to flatten object

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

Describe when multicast is useful, and its limitations

A

Useful for: Needing to talk to many servers (Twitch, video game multiplayer servers)

Limitations: Sent out of order, no acks, data loss

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

What are the pros and cons of polling for a server?

A

Pros:
can still doing some things while loading/waiting, can get whatever is there (even if just a little bit) e.g. low quality YouTube video

Cons:
- possible infinite loop, high CPU usage maybe

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

What’s the third option that’s not blocking or non-blocking?

A

Block to sync, if something weird happens, timeout socket to close

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

In a very general and lazy sense, when to use TCP and UDP?

A

TCP does things for us on the protocol level that we don’t have to worry about

Use UDP when TCP is not suitable

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

How to get message back with UDP?

A

Along with your message, send your return address (also could be anything, DOSing)

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

What’s the function for TCP to keep a connection?

A

Select! Allows to keep sending messages as they wish. Select unblocks when something happens

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

What are the TCP advantages?

A

1) Connection-oriented
2) Reliable, delivery and order is guaranteed

  • Generally used for most applications
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are the TCP disadvantages?

A
  • more bandwidth (lots of protocol overhead)
  • no broadcast/multicast support
  • slower than UDP
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are the UDP advantages?

A
  • connectionless (no 3-way handshake)
  • support multicast
  • fast + lighter than TCP
  • support live/real-time data transmission
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are the UDP disadvantages?

A
  • messages can be out of order
  • unreliable data transfer
  • usually treated as less important by router than TCP
How well did you know this?
1
Not at all
2
3
4
5
Perfectly