Changeset 151 for trunk/instant_messenger/inc/Socket.abstract.php
- Timestamp:
- 01/18/08 15:17:58 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/instant_messenger/inc/Socket.abstract.php
r63 r151 20 20 protected final function open( $pSocket = false, $pTimeOut = 1, $pBlockingMode = 0 ) 21 21 { 22 23 22 if ( !$pSocket ) 23 return false; 24 24 25 if ( $socket = @stream_socket_client($pSocket, $errno, $errstr) ) 26 { 27 stream_set_blocking($socket, $pBlockingMode); 28 stream_set_timeout($socket, $pTimeOut); 29 } 30 return $socket; 25 if ( $socket = @stream_socket_client($pSocket, $errno, $errstr) ) 26 { 27 #stream_set_blocking($socket, $pBlockingMode); 28 #stream_set_timeout($socket, $pTimeOut); 29 stream_set_blocking($socket, 1); 30 stream_set_timeout($socket, 1); 31 } 32 return $socket; 31 33 } 32 34 33 34 35 36 35 protected final function blocking($pSocket = false, $pBlockingMode = 1) 36 { 37 if ( !$pSocket || !is_resource($pSocket) ) 38 return false; 37 39 38 39 40 stream_set_blocking($pSocket, $pBlockingMode); 41 } 40 42 41 43 42 44 protected function read( $pSocket = false, $pLength = 4096 ) 43 45 { 44 45 46 ini_set( 'track_errors', '1' ); 47 $php_errormsg = ''; 46 48 47 48 49 if ( !$pSocket || !is_resource($pSocket) ) 50 return false; 49 51 50 51 52 52 set_magic_quotes_runtime(0); 53 $return = @fread($pSocket, $pLength); 54 set_magic_quotes_runtime(get_magic_quotes_gpc()); 53 55 54 56 55 56 57 if ( $php_errormsg ) 58 return false; 57 59 58 60 return $return; 59 61 } 60 62 61 63 protected function write( $pSocket = false, $pData = false ) 62 64 { 63 ini_set( 'track_errors', '1' ); 64 $php_errormsg = ''; 65 66 if ( (!$pSocket || !is_resource($pSocket)) || !$pData ) 67 return false; 65 ini_set( 'track_errors', '1' ); 66 $php_errormsg = ''; 68 67 69 $return = @fwrite($pSocket, $pData); 70 71 if ( $php_errormsg ) 72 return false; 68 if ( (!$pSocket || !is_resource($pSocket)) || !$pData ) 69 return false; 73 70 74 return $return; 71 $return = @fwrite($pSocket, $pData); 72 73 if ( $php_errormsg ) 74 return false; 75 76 return $return; 75 77 } 76 78 77 79 protected final function close( $pSocket = false ) 78 80 { 79 80 81 if ( !$pSocket || !is_resource($pSocket) ) 82 return false; 81 83 82 84 return fclose($pSocket);
Note: See TracChangeset
for help on using the changeset viewer.