Network Programming Flashcards
What does Socket API do?
it allows processes to communicate with eachother across the network. It also allows you to write programs that are largely independent of lower protocols.
How does a Socket API work?
Two sockets are required for an end-to-end communication. The sockets must be created at both ends, binded to a named local address, and optionally connected to a (remote) socket. A socket identifier is then returned (similar to a file ID) which is passed to forked (system call) child processes to support multithread processing.
What are the three types of sockets supported by the Java networking package?
Stream sockets
Datagram sockets
Multicast sockets
What is a stream socket and when would you use it?
It is socket that allows processes to communicate using TCP. It provides bidirectional, reliable, sequences, and unduplicated flow of data with no record boundaries. They are used for file transfer type applications for reliability.
What is a datagram socket and when would it be used?
It is a socket that allows processes to use UDP to communciate. It supports bidirectional flow of messages. Can receive messages in a different order than sent and can receive duplicate messages. It is used for VOIP type applications.
Explain both communication types.
Socket-based communication: (TCP) applications view networking as streams of data. It is a connection-based protocol. File I/O stream is used to read/write from sockets.
Packet-based communication: (UDP) individual packets transmitted, uses a connectionless service. Useful when you want to use flow control etc.
What is a socket?
one end-point of a two way communication link between two programs running on the network.
What are the two socket classes? Why are they used?
socket and serverSocket
They are used to represent the connection between a client program and a server program.
Describe how a connectionless server/client transmission works.
There is no connection maintained with the other computer. The message is broken down into equal sized pieces and sent as packets. There is no guarantee that messages arrive, or that they arrive in order. The receiver puts the message in order and reads them.