Login   Register  
PHP Classes
elePHPant
Icontem

File: clasemsocket.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of markitos  >  msocket  >  clasemsocket.php  >  Download  
File: clasemsocket.php
Role: ???
Content type: text/plain
Description: msocket main class
Class: msocket
Simple class to use php sockets
Author: By
Last change:
Date: 2002-06-27 08:21
Size: 947 bytes
 

Contents

Class file image Download
<?
class msocket
{
var $Hostname;
var $Port;
var $Socket;

function msocket ($Hostname, $Port=80)
{
	$this->Hostname = $Hostname;
	$this->Port     = $Port;
	return $this;
}

function EnviaRecibe ($Mensaje)
{
	$Retorno=0;
	$this->Envia ($Mensaje);
	$Retorno = $this->Recibe();
	return $Retorno;	
}

function Envia ($Mensaje)
{
	$Retorno=0;
	$this->_Conecta();
	$Retorno = fwrite ($this->Socket, $Mensaje);
	return $Retorno;
}

function Recibe()
{
	$Retorno='';
	if (!$this->Socket){ return $Retorno; }	
	while (!feof ($this->Socket))
		{$Retorno .= fgets ($this->Socket, 4096);}
	$this->_Desconecta();
	return $Retorno;
}

function _Conecta()
{
	$Retorno =0;
	$this->Socket =fsockopen($this->Hostname , $this->Port , &$err_num, &$err_msg, 30);
	$Retorno = $this->Socket;
	return $Retorno;
}

function _Desconecta()
{
	$Retorno =0; 
	$Retorno =fclose ($this->Socket);
	return $Retorno;
}

}
?>