Velocity Reviews

Velocity Reviews (
-   General Computer Support (
-   -   Why this application works differently in a mobile phone and an emulator? (

Confused 12-05-2010 07:28 AM

Why this application works differently in a mobile phone and an emulator?
I want to send a message to my computer actually connected to the internet from my mobile phone. I am able to use this program with a java emulator and it works fine however, when I deploy it on my mobile phone, it does not work ,just asks me if I want to connect to the internet and does not respond as expected..

My client codes ::

public void startApp() {
try {
// establish a socket connection with remote server
streamConnection =

// create DataOuputStream on top of the socket connection
outputStream = streamConnection.openOutputStream();
dataOutputStream = new DataOutputStream(outputStream);

// send the HTTP request

// create DataInputStream on top of the socket connection
inputStream = streamConnection.openInputStream();
dataInputStream = new DataInputStream(inputStream);
// retrieve the contents of the requested page from Web server
String test="";
int inputChar;
int avai= dataInputStream.available();
byte[] bt=new byte[avai];, 0, avai);
//, 0, avai);
for (int t=0;t<bt.length;t++){
System.out.println((char ) bt[t]);

System.out.println("Leaving read...........");
// display the page contents on the phone screen
//System.out.println(" Result are "+results.toString());
System.out.println(" ");
resultField = new StringItem(null, results.toString());
System.out.println("Client says "+resultField);

} catch (IOException e) {
System.err.println("Exception caught:" + e);
} finally {
// free up I/O streams and close the socket connection
try {
if (dataInputStream != null)
} catch (Exception ignored) {}
try {
if (dataOutputStream != null)
} catch (Exception ignored) {}
try {
if (outputStream != null)
} catch (Exception ignored) {}
try {
if (inputStream != null)
} catch (Exception ignored) {}
try {
if (streamConnection != null)
} catch (Exception ignored) {}


Server codes
public static void main(String[] args) {
// TODO code application logic here
ServerSocket sck=new ServerSocket(880);
Socket client=sck.accept();
InputStream inp= client.getInputStream();
int i;
OutputStream out=client.getOutputStream();
out.write("Testing \r\n".getBytes());

System.out.println("Server has responded ");
String str="";
int len=inp.available();
byte[] bu=new byte[len];
System.out.println("Length is"+len);,0,len);

for (int ii=0;ii<bu.length;ii++){

catch(Exception e){
System.out.println("Error "+e);


The above program works fine when I use it in an emulator but as I deploy it on my mobile phone, it just prompts me if I want to connect to the Network and stays idle..
Why such a difference?

All times are GMT. The time now is 12:42 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.