2. What is GCF?
-The GCF is a straightforward hierarchy of interfaces and classes to create connections (such
as HTTP, datagram, or streams) and perform I/O.(Oracle)
- GCF is a set of interfaces defined within the javax.microedition.io package.(IBM)
-generalization is possible through the use of:
I. An interface hierarchy that is extensible
II. A connection factory
III. Standard Uniform Resource Locators (URLs) to indicate the connection types to create
3. I) An interface hierarchy that is extensible:-
New connection types, which are defined and standardized via the Java Community
Process (JCP), can be added by defining a new Connection subtype and supporting classes,
providing a Connector factory class that supports the newly defined connection type, and
defining a new URL scheme that identifies the new connection type.
II)Connection Factory: A connection factory is the object a client uses to create
a connection to a provider. It encapsulates a set of connection configuration parameters that
has been defined by an administrator.
III) A URL (Uniform Resource Locator), as the name suggests, provides a way to locate a
resource on the web, the hypertext system that operates over the internet. The URL contains
the name of the protocol to be used to access the resource and a resource name. The first part
of a URL identifies what protocol to use. The second part identifies the IP address or domain
name where the resource is located.
4. The CLDC Generic Connection Framework Interface
Hierarchy and Related Classes
6. 1)Connection:This method closes the connection.
The Connection interface has one method:
void close
2) InputConnection:
The InputConnection interface has two methods:
DataInputStream openDataInputStream()
This method opens a data input stream from the connection.
InputStream openInputStream()
This method opens an input stream from the connection.
7. 3)OutputConnection:
The OutputConnection interface has two methods:
i)DataOutputStream openDataOutputStream()
This method opens a data output stream from the connection.
ii)OutputStream openOutputStream()
This method opens an output stream from the connection.
4) DatagramConnection
The DatagramConnection interface is used to create a datagram for a UDP communication.
int getMaximumLength()
This method returns the maximum length that is allowed for a datagram packet.
int getNominalLength()
This method returns the nominal length for datagram packets.
Datagram newDatagram(byte[] buf, int size)
This method creates a new Datagram object. Ais the placeholder for the data packet, and size is the
length of the buffer to be allocated for the Datagram object.
8. • Datagram newDatagram(byte[] buf, int size, String addr)
• This method creates a new Datagram object. The additional parameter addr specifies the
destination of this datagram message. It is in the format {protocol}://[{host}]:{port}.
• Datagram newDatagram(int size)
• This method creates a new Datagram object with an automatically allocated buffer with
length size.Datagram newDatagram(int size, String addr)
• This method creates a new Datagram object. addr specifies the destination of this datagram
message.
• void receive(Datagram dgram)
• This method receives a Datagram object dgram from the remote host.
• void send(Datagram dgram)
• This method sends a Datagram object dgram to the remote host.
9. 5) StreamConnection
The StreamConnection interface offers both send and receive capabilities for socket-based
communication. All four of its methods are inherited from InputConnection and
OutputConnection:
• DataInputStream openDataInputStream()
• InputStream openInputStream()
• DataOutputStream openDataOutputStream()
• OutputStream openOutputStream()
6) StreamConnectionNotifier
The StreamConnectionNotifier interface has one method:
• StreamConnection acceptAndOpen()
This method returns a StreamConnection that represents a server-side socket connection to
communicate with a client.
10. 7) ContentConnection
• The ContentConnection interface extends from StreamConnection and adds three methods to
determine an HTTP stream's character encoding, MIME type, and size:
i) String getEncoding()
• This method returns the value of the content-encoding in the HTTP header of an HTTP stream.
• long getLength()
• This method returns the value of the content-length in the HTTP header of an HTTP stream.
ii)String getType()
• This method returns the value of the content-type in the HTTP header of an HTTP stream.
• The methods inherited from StreamConnection are as follows:
• DataInputStream openDataInputStream()
• InputStream openInputStream()
• DataOutputStream openDataOutputStream()
• OutputStream openOutputStream()
11. 8)HttpConnection
• The HttpConnection extends from ContentConnection.The HttpConnection interface is
mandatory for all MIDP vendor implementations. It adds the following methods to
support the HTTP 1.1 protocol:
long getDate()
long getExpiration()
String getFile()
String getHeaderField(int index)
String getHeaderField(String name)
long getHeaderFieldDate(String name, long def)
int getHeaderFieldInt(String name, int def)
String getHeaderFieldKey(int n)