Java Sockets Flashcards
How do machines connect to the internet?
Using either TCP or UDP.
It’s a layered system
Your programs will be at the application layer.
TCP properties
Same as a telephone conversation
Link between 2 machines
TCP guarantees the order of data once the machine and port is established
Essential to HTTP FTP telnet etc
UDP properties
UDP is similar to postal service
Order is not guaranteed and neither is delivery.
UDP does not have the error checking and ordering overheads of TCP.
UDP is not connection based. It sends datagrams from one app to another.
What are ports?
Ports allow a computer to siphon data to the different applications running on the machine.
Data over the internet has an ip address and port associated with it.
In UDP the datagram packet contains the port number and is routed based on that.
What are sockets?
A server will run on a specific PC (IP address) and has a socket bound to a particular port for a client to make a request
The client must know the server hostname and port where the server will be listening.
The client needs its own port to accept communication from the server.
Steps for reading from/writing to sockets
Open socket Open input and output stream to socket Read and write from stream accoring to protocol Close streams Close socket.