It has been a while since this question was asked, 3 years+ but had the very same problem with a Hospital client that still has a pager system like this and also said we have given you the ip and port make it work.
Used php to open a socket connection to the server and port. Then sending the required TAP commands and getting responses from the server.
The server I was targeting did not require a username or password to log in and instead of reading the responses and looping to wait for them which could be done with socket_read($socket, 1024); I just paused the script for two seconds before sending the next command. Server did not like it when I closed the socket and ended up letting the server do this after sending the end of message sequence. You could send more than one message if you omit the end of message part, but the server i had to deal with crashed a lot and the below worked for me. the client will buy a new system in 6 months time with a far better interphase, therefore not looking into this any further.
//$msg_to = the pager number
//$msg_text = the message
//$host = ip of server
//$port = port number
$message = chr(2).$msg_to.chr(13).$msg_text.chr(13).chr(3);
$checksum = calcChecksum($message);
$message .= $checksum.chr(13);
$CR = chr(13);
$end = chr(27).chr(4).chr(13); //<ESC><EOT><CR>
$login = chr(27)."PG1".chr(13); //<ESC>PG1thepwd<CR>
//- <ACK><CR><ESC>[p<CR> check for [p
$socket = socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not create socket");
$result = socket_connect($socket, $host, $port) or die("Could not connect to server");
sleep(1); stream_set_timeout($socket, 5);
socket_write($socket, $CR, strlen($CR)) or die("Could not send <CR> to server");
sleep(2);
socket_write($socket, $message, strlen($message)) or die("Could not send message to server");
sleep(2);
socket_write($socket, $end, strlen($end)) or die("Could not send end to server");
function calcChecksum($message) {
$split = str_split($message); $sum = 0;
foreach ($split as $value) { $numb = ord($value); $sum += $numb; }
$d3 = 48 + $sum - intval($sum / 16) * 16;
$sum = intval($sum / 16);
$d2 = 48 + $sum - intval($sum / 16) * 16;
$sum = intval($sum / 16);
$d1 = 48 + $sum - intval($sum / 16) * 16;
return chr($d1).chr($d2).chr($d3);
};