- Timestamp:
- 07/14/07 11:22:05 PM (18 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/LogicMail/src/org/logicprobe/LogicMail/util/Connection.java
r129 r130 63 63 import java.io.InputStream; 64 64 import java.io.OutputStream; 65 import java.util.Vector; 65 66 import javax.microedition.io.SocketConnection; 66 67 import javax.microedition.io.StreamConnection; … … 114 115 */ 115 116 private int count; 116 117 /** 118 * Holds the position of the next byte to be read from the buffer.119 */ 120 //private int position;117 118 /** 119 * Holds a list of open connections 120 */ 121 private static Vector openConnections = new Vector(); 121 122 122 123 public Connection(String serverName, int serverPort, boolean useSSL, boolean deviceSide) { … … 136 137 public void open() throws IOException { 137 138 close(); 139 140 synchronized(openConnections) { 141 if(!openConnections.contains(this)) { 142 openConnections.addElement(this); 143 } 144 } 145 138 146 String protocolStr = (useSSL ? "ssl" : "socket"); 139 147 // This param, which allows bypassing the MDS proxy, should probably … … 166 174 socket.close(); 167 175 socket = null; 176 } 177 178 synchronized(openConnections) { 179 if(openConnections.contains(this)) { 180 openConnections.removeElement(this); 181 } 182 } 183 } 184 185 /** 186 * Determine whether open connections exist 187 * 188 * @return True if there are open connections 189 */ 190 public static boolean hasOpenConnections() { 191 boolean result; 192 synchronized(openConnections) { 193 result = !openConnections.isEmpty(); 194 } 195 return result; 196 } 197 198 /** 199 * Close all open connections 200 */ 201 public static void closeAllConnections() { 202 synchronized(openConnections) { 203 int size = openConnections.size(); 204 for(int i = 0; i < size; i++) { 205 try { 206 ((Connection)openConnections.elementAt(i)).close(); 207 } catch (IOException e) { } 208 } 209 openConnections.removeAllElements(); 168 210 } 169 211 }
