Network Connection (Cont.)
- The Connection interface is the most basic connection type.
It can only be opened and closed.
- The InputConnection interface represents a device from which data can be read.
Its openInputStream method returns an input stream for the connection.
- The OuputConnection interface represents a device to which data can be written.
Its openOutputStream method returns an output stream for the connection.
- The StreamConnection interface combines the input and output connections.
- The ContentConnection is a subinterface of
StreamConnection
.
It provides access to some of the basic meta data information provided by HTTP connections.
- The StreamConnectionNotified waits for a connection to be established.
It returns a
StreamConnection
on which a communication link has ben established.
- The DatagramConnection represents a datagram endpoint.
The open method of the Connector class has the following syntax, where the String
parameter has the format "protocol:address;parameters
".
Connector.open(String);
Below are few examples:
HTTP connection:
Connector.open("http://java.sun.com/developer");
Datagram connection:
Connector.open("datagram://address:port#");
Communicate with a port:
Connector.open("comm:0;baudrate=9600');
Open files:
Connector.open("file:/myFile.txt");