Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 445
Registered: ‎10-14-2008
My Device: Blackberry Bold 9000
My Carrier: SingTel

OutputStreamWriter

I am in trouble now.

 

my code communiation with a socket server. my bberry sample app GPSDemo connecting succesfully and receiving data from the socket server but its not sending data to the socket server.

 

I dont know where i am wrong. I am trying from last 2 days but not get success.

 

Here is the code snippet.

 

 

private static String host = "192.168.168.135:8080";

 

 

 

 

_url = "socket://" + host + ";deviceside=true;apn=wap.cingular;TunnelAuthUsername=WAP@CINGULARGPRS.COM;TunnelAuthPassword=CINGULAR1";

 

 

 

 

StreamConnection connection = null; try { connection = (StreamConnection)Connector.open(_url, Connector.READ_WRITE, false); _in = new InputStreamReader(connection.openInputStream()); _out = new OutputStreamWriter(connection.openOutputStream()); //write the data to the server // data = "$RGTK,1234,12082005125349,A,23.8547,E,61.4496,N,11,0,0,9,0,0,0,0,0,20081230071138&"; _out.write(data); //_out.write(52); System.out.println("Sent................."); _out.write('z'); //write a terminator //wait for an ack, in this case an 'R' character, for 'Received' int c = _in.read(); while(c > -1) { System.out.println("Char :: " + (char)c); c = _in.read(); } //debug // System.out.println("GPSDemo: Debug: exchange(): received ack char:" + c); _delay = DEFAULT; //reset the backoff delay error = false; //clear any error } catch (IOException e) { System.out.println("Error Zahid : "+e.getMessage()); error = true; _delay = increaseDelay(_delay); GPSDemo.this.updateLocationScreen(e.toString()); //push this data back on the stack, it's still pending synchronized (this) { _data.insertElementAt(data, 0); } } finally { try { if(_in!=null) _in.close(); if(_out!=null) _out.close(); //if(connection!=null) connection.close(); } catch (Exception ioe) { //no-op - we don't care on close } } } }

 

 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Thanks & Regards
Zahid Naqvi | Senior Software Engineer
Developer
Posts: 46
Registered: ‎07-12-2008
My Device: Not Specified

Re: OutputStreamWriter

Have you tried calling the flush() method on the OutputStreamWriter?
Developer
Posts: 445
Registered: ‎10-14-2008
My Device: Blackberry Bold 9000
My Carrier: SingTel

Re: OutputStreamWriter

yes i tried.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Thanks & Regards
Zahid Naqvi | Senior Software Engineer
BlackBerry Development Advisor
Posts: 15,727
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: OutputStreamWriter

It looks like you are connecting to a non public IP address of 192.168.168.135.  This would not be accessible over a carrier's network (which looks to be Cingular judging by your APN) since it would be unable to route to this address.  If you wish to connect to a server within your Intranet you could connect through your BlackBerry Enterprise Server (deviceside=false).
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Highlighted
Developer
Posts: 445
Registered: ‎10-14-2008
My Device: Blackberry Bold 9000
My Carrier: SingTel

Re: OutputStreamWriter

//_url = "socket://" + host + ";deviceside=true;apn=wap.cingular;TunnelAuthUsername=WAP@CINGULARGPRS.COM;TunnelAuthPassword=CINGULAR1"; _url = "socket://" + host + ";deviceside=false";

 

First I tried

//_url = "socket://" + host + ";deviceside=true;apn=wap.cingular;TunnelAuthUsername=WAP@CINGULARGPRS.COM;TunnelAuthPassword=CINGULAR1"; 

 

Now i m trying

_url = "socket://" + host + ";deviceside=false";

 

both are working same like connecting to server and receiving data from the server but both unable to send data to server.

 

for more info. Click here.......

 

 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Thanks & Regards
Zahid Naqvi | Senior Software Engineer