Hi
I am running the PHP Socket Server:
#!/usr/bin/php -q
<?php
error_reporting(E_ALL);
set_time_limit(0);
ob_implicit_flush();
$address = '127.0.0.1';
$port = 9999;
function send_Message($allclient, $socket, $buf) {
foreach($allclient as $client) {
socket_write($client, "$socket wrote: $buf");
}}
if (($master = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) < 0) {
echo "socket_create() failed, reason: " . socket_strerror($master) .
"\n";
}
socket_set_option($master, SOL_SOCKET,SO_REUSEADDR, 1);
if (($ret = socket_bind($master, $address, $port)) < 0) {
echo "socket_bind() failed, reason: " . socket_strerror($ret) . "\n";
}
if (($ret = socket_listen($master, 5)) < 0) {
echo "socket_listen() failed, reason: " . socket_strerror($ret) .
"\n";
}
$read_sockets = array($master);
while (true) {
$changed_sockets = $read_sockets;
$num_changed_sockets = socket_select($changed_sockets, $write = NULL,
$except = NULL, NULL);
foreach($changed_sockets as $socket) {
if ($socket == $master) {
if (($client = socket_accept($master)) < 0) {
echo "socket_accept() failed: reason: " . socket_strerror($msgsock) .
"\n";
continue;
} else {
array_push($read_sockets, $client);
}} else {
$bytes = socket_recv($socket, $buffer, 2048, 0);
if ($bytes == 0) {
$index = array_search($socket, $read_sockets);
unset($read_sockets[$index]);
socket_close($socket);
}else{
$allclients = $read_sockets;
array_shift($allclients);
send_Message($allclients, $socket, $buffer);
}}}}
?>
I activate it with the *.bat file:
c:/php/php.exe -q c:/Apache/htdocs/socketServer.php
But I want to use it at the external server and there is no way to
activate it there (no access to command line).
My question: is it possible not to use such a server in the daemon-
mode but to activate it on-demand (by Flash client)? 4 3013
On Aug 3, 1:13 am, bartosz.zale...@gmail.com wrote:
Hi
I am running the PHP Socket Server:
#!/usr/bin/php -q
<?php
error_reporting(E_ALL);
set_time_limit(0);
ob_implicit_flush();
$address = '127.0.0.1';
$port = 9999;
function send_Message($allclient, $socket, $buf) {
foreach($allclient as $client) {
socket_write($client, "$socket wrote: $buf");
}}
if (($master = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) < 0) {
echo "socket_create() failed, reason: " . socket_strerror($master) .
"\n";
}
socket_set_option($master, SOL_SOCKET,SO_REUSEADDR, 1);
if (($ret = socket_bind($master, $address, $port)) < 0) {
echo "socket_bind() failed, reason: " . socket_strerror($ret) . "\n";
}
if (($ret = socket_listen($master, 5)) < 0) {
echo "socket_listen() failed, reason: " . socket_strerror($ret) .
"\n";
}
$read_sockets = array($master);
while (true) {
$changed_sockets = $read_sockets;
$num_changed_sockets = socket_select($changed_sockets, $write = NULL,
$except = NULL, NULL);
foreach($changed_sockets as $socket) {
if ($socket == $master) {
if (($client = socket_accept($master)) < 0) {
echo "socket_accept() failed: reason: " . socket_strerror($msgsock) .
"\n";
continue;} else {
array_push($read_sockets, $client);}} else {
$bytes = socket_recv($socket, $buffer, 2048, 0);
if ($bytes == 0) {
$index = array_search($socket, $read_sockets);
unset($read_sockets[$index]);
socket_close($socket);}else{
$allclients = $read_sockets;
array_shift($allclients);
send_Message($allclients, $socket, $buffer);}}}}
?>
I activate it with the *.bat file:
c:/php/php.exe -q c:/Apache/htdocs/socketServer.php
But I want to use it at the external server and there is no way to
activate it there (no access to command line).
My question: is it possible not to use such a server in the daemon-
mode but to activate it on-demand (by Flash client)?
If I'm not mistaken you can... but let the other ppl from the
newsgroup clarify me.
You can do this by issuing the following command:
exec('start c:/php/php.exe -q c:/Apache/htdocs/socketServer.php');
But if you haven't got access to command line on the other server
(I'm assuming it's a web-host), I highly doubt you can *listen* to any
port
due to firewall restriction.
Hendri Kurniawan
So is there no other way to establish socket-server than to run it on
my own server? ba*************@gmail.com wrote:
So is there no other way to establish socket-server than to run it on
my own server?
Hendri is correct - if this is a shared server, chances are you won't be
allowed to run it.
Can you imagine what it would be like if 100 websites all tried to use
the same port?
You can get your own dedicated server or even a VPS. That way you have
(pretty much) complete control over the system.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attglobal.net
==================
Not good :/
Anyway thanks lads for info. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Rune |
last post by:
Hi,
I've written a very simple 'kill-server' to help me shut down
processes through Telnet or HTTP. The kill-server is a function and is
launched as a thread. I use the module socket.py on Python...
|
by: Fuzzyman |
last post by:
I'm trying to create a proxy server - one that will modify requests
made through it.
I've started with Tiny HTTP Proxy by SUZUKI Hisao which is built on
BaseHTTPServer - and I'm starting to get...
|
by: Marc Bogaard |
last post by:
Hello all!
I am trying to develop some kind of proxy which filters the data the
browser
sents to a webserver (www.google.de, www.gmx.net, ...). For this
reason I set a Proxy Connection in my IE...
|
by: |
last post by:
Hi all,
I have a simple .aspx page running on net 2.0 that is trying to do a http
post to a remote server. Here is the code
Private Function ProcessRequests(ByVal strbody As String) As String...
|
by: KL |
last post by:
Hey...I am working on a project for school. I preface this so everyone
understands that I don't want the full answer, rather a nudge in the
correct direction.
The following code section is...
|
by: doc |
last post by:
Hi
Hard to know where to post this and I don't want to double post it - please move it if you need to,
I am trying to connect a Flash client socket (XML) to a php socket server (using Flash 8 and...
|
by: =?Utf-8?B?Sm9obg==?= |
last post by:
Hi all,
I am new to .net technologies.
ASP.NET supports socket programming like send/receive in c or c++?
I am developing web-site application in asp.net and code behind is Visual
C#. In...
|
by: vasu1308 |
last post by:
Hi all
I am working on a socket program in Perl. Main goal is to develop a proxy server. Here is the code attached. An error is encountered. Anyone Please help me out.
#!/usr/bin/perl -w
#...
|
by: Wade Yin |
last post by:
Hi,
If I can write a ActiveX component that can support socket
communication in webpage, that will make browser have strongger
capability to communicate with different clients, but not only can...
|
by: george585 |
last post by:
Hello!
I am new to network programming, and understand just basics. Using some sample code, and having read documentation, I managed to create a simple app in C# and VB.NET. The application is...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |