Motorola E680 Technical Manual - Page 42
Socket Connection
View all Motorola E680 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 42 highlights
Connector class in the javax.microedition.io.package Dynamic DNS allocation through DHCP Supported Supported HttpConnection interface in the javax.microedition.io.package. Supported HttpsConnection interface in the javaxmicroedition.io.package Supported SecureConnection interface in the javax.microedition.io.package Supported SecurityInfo Interface in the javax.microedition.io.package Supported ServerSocketConnection interface in the javax.microedition.io.package Supported UDPDatagramConnection interface in the javax.microedition.io.package Supported The following is a code sample to show implementation of Socket Connection: Socket Connection import javax.microedition.io.*; import java.io.*; import javax.microedition.midlet.*; .... try { //open the connection and io streams sc = (SocketConnection)Connector.open("socket://www.myserver.com :8080", Connector.READ_WRITE, true); is = sc[i].openInputStream(); os = sc[i].openOutputStream(); } catch (Exception ex) { closeAllStreams(); System.out.println("Open Failed: " + ex.getMessage()); } } if (os != null && is != null) { try { os.write(someString.getBytes()); //write some data to server 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, 42