posted 19 years ago
to Marcin Zduniak
the question is, why i can run the coding on wtk emulator but not on the nokia devices (n6260)
to Maddi Ranjan
im not sure that ur problem is same with me or not..
but i hv found solution for my problem.
for nokia to send data thru outputstream u must flush the data and close the connection. then u open connection to the same server and execute the inputStream to get the respond message process by the server from your previous data.
something like this..
//open conn
sc = (SocketConnection) Connector.open("socket://" + xconnStr);
//prepare data to be send
data = "some command";
DataOutputStream os = sc.openDataOutputStream();
os.write(data);
os.flush();
os.close();
/-------------------------------------------------------------------------
//diff method or class
//then, to receive respond from the host..
//open conn
sc = (SocketConnection) Connector.open("socket://" + xconnStr);
InputStream is = sc.openInputStream();
// read server response
StringBuffer sb = new StringBuffer();
int c = 0;
while ( ( (c = is.read()) != '\f') && (c != -1)) {
sb.append( (char) c);
if (c == -1) {
break;
}
}
return sb.toString();
[ June 30, 2005: Message edited by: rashidi ahad ]