WebSockets Flashcards
Network connection
A relationship between two machines, where two pieces of software know about each other
Socket declaration
Socket chatsocket = new Socket(“196.164.1.103”, 5000);
Socket connection
Two machines have information about each other, including network location (IP address) and TCP port
TCP port
A 16-bit numbers that identifies a specific program on the server
What happen without port numbers?
The server would have no way of knowing which application a client wanted to connect to
Why use TCP after 1024?
Because 0 through 1023 are reserved for the well-known services
How do you know the port number of the server program you want to talk to?
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
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?
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 do you get messages from the server?
When you set up the networking make an input stream as well (probably a BufferedReader). Then read messages using readLine()
Thread
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.
Runnable
Runnable is to a Thread what a job is to a worker. A Runnable is the job a thread is supposed to run