This is the code snipit from the OS 6 API:
Code:
SocketConnection sc = (SocketConnection)
Connector.open("socket://host.com:79");
sc.setSocketOption(SocketConnection.LINGER, 5);
InputStream is = sc.openInputStream();
OutputStream os = sc.openOutputStream();
os.write("\r\n".getBytes());
int ch = 0;
while(ch != -1) {
ch = is.read();
}
is.close();
os.close();
sc.close();
Any code that may block (such as socket reads or writes) must be run on a thread separate from the event thread.