BlackBerry Forums Support Community
              

Closed Thread
 
LinkBack Thread Tools
Old 10-04-2007, 06: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, 08: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, 01: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

HP SWITCH 33124A 12.4 GHz RF MICROWAVE FREQUENCY BIN#F6-32
$119.0
HP SWITCH 33124A 12.4 GHz  RF MICROWAVE FREQUENCY BIN#F6-32 pictureAutomatic Transfer Switch Power Switch Electrical
$45.0
Automatic Transfer Switch Power Switch Electrical picture3dRose lsp_29661_1 Blue Leather Like Single Toggle Switch
$23.87
3dRose lsp_29661_1 Blue Leather Like Single Toggle Switch picture50 PCS BSP75N SOT-223 BSP75 Smart Lowside Power Switch
$16.99
50 PCS BSP75N SOT-223 BSP75 Smart Lowside Power Switch picture1PC New Cisco CATALYST 2960 WS-C2960-24PC-L Switch
$1250.5
1PC New Cisco CATALYST 2960 WS-C2960-24PC-L Switch picture






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