Net.object
上传用户:xiao730204
上传日期:2007-01-04
资源大小:141k
文件大小:1k
- <?php
- class Net extends BaseObject {
- var $server;
- var $port;
- var $connnected;
- var $connection_handle;
- Function Net() {
- $this->BaseObject( 'Net' );
- $this->server = '';
- $this->port = '';
- $this->connected = 0;
- $this->connection_handle = undef;
- }
- Function Open() { return $this->Connect(); }
- Function Connect() {
- $this->connection_handle =
- fsockopen(
- $this->server,
- $this->port,
- $error_number,
- $error_string
- );
- if ( ! $this->connection_handle ) {
- return Array(
- false,
- 'Could not connect : ' .
- $error_number, ' - ' . $error_string
- );
- }
- $this->connected = true;
- }
- Function Close() { return $this->Disconnect(); }
- Function Disconnect() {
- return fclose( $this->connection_handle );
- }
- Function ReadLine( $buffer_len = 2048 ) {
- if ( $this->connected == true ) {
- return fgets( $this->connection_handle, $buffer_len );
- }
- }
- Function SendLine( $line ) {
- if ( $this->connected == true ) {
- return fputs( $this->connection_handle, $line );
- }
- return 0;
- }
- }
- ?>