Wracam do tematu
Wszystko co poniżej działa ale tylko na lokalu, niestety na serwerze hostingowym już niestety nie
<?php
/*************************************/
/********Socket Server*********************/
// Set the ip and port we will listen on
$address = '127.0.0.1';
$port = 3000;
// Create a TCP Stream socket
$sock = socket_create(AF_INET, SOCK_STREAM, 0); // 0 for SQL_TCP
// Bind the socket to an address/port
socket_bind
($sock, 0
, $port) or
die('Could not bind to address'); //0 for localhost// Start listening for connections
socket_listen($sock);
//loop and listen
while (true) {
/* Accept incoming requests and handle them as child processes */
$client = socket_accept($sock);
// Read the input from the client ? 1024000 bytes
$input = socket_read($client, 1024000);
// Strip all white spaces from input
// Close the master sockets
}
socket_close($sock);
?>
Te flusze to tylko po to żebym mógł z przeglądarki odpalać
Client w node
var net = require('net');
function loop(){
var client = new net.Socket();
client.connect(3000, 'xxx', function() {
console.log('Connected');
client.write('CZESC.');
});
client.on('data', function(data) {
console.log('ODEBRANO: ' + data);
client.destroy(); // kill client after server's response
});
client.on('close', function() {
console.log('Connection closed');
});
}
setInterval(loop,3000);
Nie wiem czy porty są po blokowane na serwerze i nie ma do nich dostępu czy co?
Czy można ten temat jakoś podejść jakoś inaczej np po zwykłym www port 80 tak żeby serwer tylko odebrał paczkę mimo że brak poprawnego nagłówka i np zapisał do pliku.
P.S Próbowałem też dodać takie coś w htaccess (pewnie coś tu żle napisane jest)
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^xxx.pl$ [NC]
RewriteCond %{HTTPS} off
RewriteRule ^xxx:3000%{REQUEST_URI} [P,QSA,L]