Hi
Please let me know what is the error in the following code. I am doing a tracking project. My vehicle unit has a simcard with sms message stored on it. When the unit powers up it reads the sms and enables the GPRS module(xxxgprs. com is my APN). It establishes the GPRS TCP/IP connection to my server on port 29999.
I created a php program which listens the port 29999 to receive the data transmitted by the unit.
When I run this program, I could notice the status bar it is started executing, displays nothing. When I refresh the program again, I get the following error
Warning: could not bind address[98].Address already in use.
I do not know what error? If this program is wrong please give me a php code to listen to the port 29999 to receive the values.
[code=php]
#!/usr/local/bin/php –q
<?php
// Server IP address
$address = "72.29.86.1 67";
// Port to listen
$port = 29999;
$mysock = socket_create(A F_INET, SOCK_STREAM, SOL_TCP);
socket_bind($my sock,$address, $port) or die('Could not bind to address');
socket_listen($ mysock, 5);
$client = socket_accept($ mysock);
// read 1024 bytes from client
$input = socket_read($cl ient, 1024);
// write received data to the file
writeToFile('ab c.txt', $input);
socket_close($c lient);
socket_close($m ysock);
?>
<?
/**
* write string to file
*/
function writeToFile($st rFilename, $strText)
{
if($fp = @fopen($strFile name,"w "))
{
$contents = fwrite($fp, $strText);
fclose($fp);
return true;
}else{
return false;
}
}
?> [/code]
[Please use CODE tags when posting source code. Thanks! --pbmods]
I have a dedicated server with Linux installed using a php 4.4.3.
Regards
Ushachandran
Please let me know what is the error in the following code. I am doing a tracking project. My vehicle unit has a simcard with sms message stored on it. When the unit powers up it reads the sms and enables the GPRS module(xxxgprs. com is my APN). It establishes the GPRS TCP/IP connection to my server on port 29999.
I created a php program which listens the port 29999 to receive the data transmitted by the unit.
When I run this program, I could notice the status bar it is started executing, displays nothing. When I refresh the program again, I get the following error
Warning: could not bind address[98].Address already in use.
I do not know what error? If this program is wrong please give me a php code to listen to the port 29999 to receive the values.
[code=php]
#!/usr/local/bin/php –q
<?php
// Server IP address
$address = "72.29.86.1 67";
// Port to listen
$port = 29999;
$mysock = socket_create(A F_INET, SOCK_STREAM, SOL_TCP);
socket_bind($my sock,$address, $port) or die('Could not bind to address');
socket_listen($ mysock, 5);
$client = socket_accept($ mysock);
// read 1024 bytes from client
$input = socket_read($cl ient, 1024);
// write received data to the file
writeToFile('ab c.txt', $input);
socket_close($c lient);
socket_close($m ysock);
?>
<?
/**
* write string to file
*/
function writeToFile($st rFilename, $strText)
{
if($fp = @fopen($strFile name,"w "))
{
$contents = fwrite($fp, $strText);
fclose($fp);
return true;
}else{
return false;
}
}
?> [/code]
[Please use CODE tags when posting source code. Thanks! --pbmods]
I have a dedicated server with Linux installed using a php 4.4.3.
Regards
Ushachandran
Comment