BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 10-04-2007, 07:06 AM   #1 (permalink)
Thumbs Must Hurt
 
Join Date: May 2007
Location: Bulgaria
Model: none
PIN: N/A
Carrier: Mtel
Posts: 150
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Socket Connection Problem!!!

Please Login to Remove!

I make a SocketConnection like this :

Code:
private void connect() throws IOException, ControlledAccessException, IllegalArgumentException {
    socket = (SocketConnection) Connector.open(link);
    socket.setSocketOption(SocketConnection.KEEPALIVE, 0);
    socket.setSocketOption(SocketConnection.LINGER, timeout);
  }
where link is:
Code:
String link = "socket://some host:some port;deviceside=true"
Sometimes I cannot set the connection i.e. the connect() method throws IOException. It is not all the time but sometimes. do you have an idea what is going on?
Offline  
Old 10-08-2007, 09:26 PM   #2 (permalink)
Thumbs Must Hurt
 
Join Date: Jun 2007
Model: 8800
PIN: N/A
Carrier: GPRS
Posts: 68
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Maybe you can delete the two:
" socket.setSocketOption(SocketConnection.KEEPALIVE, 0);
socket.setSocketOption(SocketConnection.LINGER, timeout);
"
just use the default configuration.
Offline  
Old 10-09-2007, 02:54 AM   #3 (permalink)
Thumbs Must Hurt
 
Join Date: May 2007
Location: Bulgaria
Model: none
PIN: N/A
Carrier: Mtel
Posts: 150
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi, I found the problem. When I opened the connection, I opened the Input and Output streams ,but when I close the connection I don't close the streams so when I made a lot of input and output streams opened it throws an IOException: max connections opened. So the problem is solved .

Code:
connect();
      InputStream in = socket.openInputStream();
      OutputStream out = socket.openOutputStream();
      //..... some code
      in.close();
      out.flush();
      out.close();
      socket.close();
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.