Java Reference
In-Depth Information
...
} catch(IOException ioe) { ... }
The security policy related to access permissions by trusted and
untrusted MIDlets is the same as the one for HTTP connections, except
that the permission setting has a different name:
MIDlet-Permissions: javax.microedition.io.Connector.https, ...
2.6.2 Socket and Server Socket Support
MIDP makes support for socket connections a recommended practice.
Socket connections come in two forms: client connections, in which a
socket connection is opened to another host; and server connections in
which the system listens on a particular port for incoming connections
from other hosts. The connections are specified using Universal Resource
Identifiers (URI). You should be familiar with the syntax of a URI from web
browsing. They have the format
< string1 > :// < string2 >
where
< string1 >
identifies the communication protocol to be used (e.g.,
http )and
provides specific details about the connection.
The protocol may be one of those supported by the Generic Connection
Framework (see Section 2.5.2).
To open a client socket connection to another host, we pass a URI of
the following form to the connector's open() method:
< string2 >
socket://www.symbian.com:5000
The host may be specified as a fully qualified hostname or IP address
and the port number refers to the connection endpoint on the remote
peer. Some sample code is shown below:
SocketConnection sc = null;
OutputStream out = null;
try {
sc = (SocketConnection)Connector.open ("socket://200.251.191.10:7900");
...
out = c.openOutputStream();
...
} catch(IOException ioe) { ... }
A server socket connection is used to listen for inbound socket con-
nections. To obtain a server socket connection, we can pass a URI in
either of the following forms to the connector's open() method:
Search WWH ::




Custom Search