- Timestamp:
- 07/27/09 16:53:20 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LogicMail/src/org/logicprobe/LogicMail/util/Connection.java
r449 r471 119 119 private boolean useWiFi; 120 120 private int fakeAvailable = -1; 121 121 private int bytesSent = 0; 122 private int bytesReceived = 0; 123 122 124 /** 123 125 * Provides a buffer used for incoming data. … … 193 195 output = socket.openDataOutputStream(); 194 196 localAddress = ((SocketConnection) socket).getLocalAddress(); 195 197 bytesSent = 0; 198 bytesReceived = 0; 199 196 200 if (EventLogger.getMinimumLevel() >= EventLogger.INFORMATION) { 197 201 String msg = "Connection established:\r\n" + "Socket: " + … … 305 309 } 306 310 311 /** 312 * Gets the number of bytes that have been sent since the 313 * connection was opened. 314 * <p> 315 * The counter is not synchronized, so it should only be 316 * called from the same thread as the send and receive 317 * methods. 318 * </p> 319 * @return bytes sent 320 */ 321 public int getBytesSent() { 322 return bytesSent; 323 } 324 325 /** 326 * Gets the number of bytes that have been received since the 327 * connection was opened. 328 * <p> 329 * The counter is not synchronized, so it should only be 330 * called from the same thread as the send and receive 331 * methods. 332 * </p> 333 * @return bytes received 334 */ 335 public int getBytesReceived() { 336 return bytesReceived; 337 } 338 307 339 /** 308 340 * Sends a string to the server. This method is used internally for … … 328 360 329 361 output.write(CRLF, 0, 2); 362 bytesSent += 2; 330 363 } 331 364 /** … … 356 389 * Write the string up to there and terminate it properly. 357 390 */ 358 output.write((s.substring(i, j) + "\r\n").getBytes()); 391 byte[] buf = (s.substring(i, j) + "\r\n").getBytes(); 392 output.write(buf); 393 bytesSent += buf.length; 359 394 360 395 /** … … 386 421 if (s == null) { 387 422 output.write(CRLF, 0, 2); 423 bytesSent += 2; 388 424 } else { 389 output.write((s + "\r\n").getBytes()); 425 byte[] buf = (s + "\r\n").getBytes(); 426 output.write(buf); 427 bytesSent += buf.length; 390 428 } 391 429 … … 402 440 */ 403 441 public synchronized void sendRaw(String s) throws IOException { 404 byte[] b ytes= s.getBytes();442 byte[] buf = s.getBytes(); 405 443 406 444 if (globalConfig.getConnDebug()) { … … 409 447 } 410 448 411 output.write(bytes, 0, bytes.length); 412 449 output.write(buf, 0, buf.length); 450 bytesSent += buf.length; 451 413 452 output.flush(); 414 453 } … … 487 526 while (true) { 488 527 int actual = input.read(buffer, count, 1); 489 528 490 529 /** 491 530 * If -1 is returned, the InputStream is already closed, … … 524 563 // approach which screws up on mid-line LFs. (DK) 525 564 else { 565 bytesReceived += actual; 566 526 567 byte b = buffer[count]; 527 568 readBytes++;
Note: See TracChangeset
for help on using the changeset viewer.
