BlackBerry Forums Support Community

BlackBerry Forums Support Community (http://www.blackberryforums.com/)
-   Developer Forum (http://www.blackberryforums.com/developer-forum/)
-   -   Error in reopening socket connection (http://www.blackberryforums.com/developer-forum/56505-error-reopening-socket-connection.html)

Wira 12-03-2006 11:04 PM

Error in reopening socket connection
 
hii guys..

I have a menu which will do this process every time user click it.
- ask user to type text
- open socket connection to server
- send the text to server
- close connection

i'am not using the BES, just connect directly to a web server, so i use deviceside=true parameter.
Code:

iSocket = (StreamConnection)Connector.open("socket://" + iServerName+ ":" + iPort + ";deviceside=true");
at the first user click this menu, the process works fine, but when the user click it again, its not working. The process will halt in the Connector.open statement for about 2 minutes and then throw exception "Unable to open connection".

i have try to debug my code, and i found that if i open connection and just read from socket it works fine on my process above, but if i open connection and try to write data to socket, it only success on the first time, the next will be fail in opening connection statement.

this is the code for read from socket:
Code:

iEngine.iSockOutputStrm.write((new String(iTransferBuffer)).getBytes());
iEngine.iSockOutputStrm.flush();

guys, please help me fix this error... thanks..
FYI, i'am testing it on emulator.


All times are GMT -5. The time now is 02:24 AM.

Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.