Table 6 Network Api Feature/Class Support For Midp 2.0 - Motorola C381P J2ME Technical Manual

J2me developer guide
Table of Contents

Advertisement

8
Network APIs
SecureConnection interface in the javax.microedition.io.package
SecurityInfo Interface in the javax.microedition.io.package
ServerSocketConnection interface in the javax.microedition.io.package Supported
UDPDatagramConnection interface in the
javax.microedition.io.package
The Code Sample 2 shows the implementation of Socket Connection:
Socket Connection
import javax.microedition.io.*;
import java.io.*;
import javax.microedition.midlet.*;
....
(SocketConnection)Connector.open("socket://www.myserver.com
:8080", Connector.READ_WRITE, true);
ex.getMessage());
some data to server
bytes_left);

Table 6 Network API feature/class support for MIDP 2.0

try {
//open the connection and io streams
sc =
is = sc[i].openInputStream();
os = sc[i].openOutputStream();
} catch (Exception ex) {
closeAllStreams();
System.out.println("Open Failed: " +
}
}
if (os != null && is != null)
{
try
{
os.write(someString.getBytes()); //write
int bytes_read = 0;
int offset = 0;
int bytes_left = BUFFER_SIZE;
//read data from server until done
do
{
bytes_read = is.read(buffer, offset,
if (bytes_read > 0)
{
offset += bytes_read;
bytes_left -= bytes_read;
}
Supported
Supported
Supported
31

Advertisement

Table of Contents
loading

Table of Contents