WebSockets Flashcards

1
Q

Network connection

A

A relationship between two machines, where two pieces of software know about each other

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

Socket declaration

A

Socket chatsocket = new Socket(“196.164.1.103”, 5000);

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

Socket connection

A

Two machines have information about each other, including network location (IP address) and TCP port

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

TCP port

A

A 16-bit numbers that identifies a specific program on the server

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

What happen without port numbers?

A

The server would have no way of knowing which application a client wanted to connect to

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

Why use TCP after 1024?

A

Because 0 through 1023 are reserved for the well-known services

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

How do you know the port number of the server program you want to talk to?

A

You need to find out from whoever is deploying the service. Ask him. Or her. Typically, if someone writes a network service and wants others to write clients for it, they’ll publish the IP address, port number, and protocol for the service

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

Can there ever be more than one program running on a single port? In other words, can two applications on the same server have the same port number?

A

No! You will get BindException. To bind a program to a port just means starting up a server application and telling it to run on a particular port.

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

How do you get messages from the server?

A

When you set up the networking make an input stream as well (probably a BufferedReader). Then read messages using readLine()

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

Thread

A

A thread is a separate ‘thread of execution’. In other words, a separate call stack. A thread is a Java class that represents a thread.

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

Runnable

A

Runnable is to a Thread what a job is to a worker. A Runnable is the job a thread is supposed to run

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