how to communication with the Access Controller?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
samuelxin
Forum Newbie
Posts: 1
Joined: Mon Aug 15, 2005 11:56 pm

how to communication with the Access Controller?

Post by samuelxin »

Hi every one
i have a Access Controller mechine
want send data and get the data from server

the retailer say i can use the TCP/IP to communication with it
i try meny time, use the socket, but fail.
could you teach me how to
thank you

code

Code: Select all

$ip='280.88.287.18';  // i used also udp, but fail  udp://280.88.287.18 
$port=4660;             //port 
$packet = '078000052'; // send the data, ascii code 
 $fp = fsockopen($ip, $port, $errno, $errstr, 30); // 

fwrite($fp, $packet); //send data 

while (!feof($fp)) { 
    $data=fread($fp, 26);  // read 
    echo $data; 
}
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

Might want to add a newline to your command:

Code: Select all

$ip='280.88.287.18';
$port=4660;
$packet = '078000052' . "\n";
  
$fp = fsockopen($ip, $port, $errno, $errstr, 30);
if (!$fp) 
{
   echo "$errstr ($errno) <br/>";
}
else
{
  fwrite($fp, $packet);

  while (!feof($fp)) 
  {
    $data=fgets($fp, 128);
    echo $data;
  }
}
Post Reply