469,356 Members | 2,626 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,356 developers. It's quick & easy.

flash xml socket will not connect to php socket server

8
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 php 5).
My php socket server responds correctly when I connect to it with a php client socket but I cannot connect with the flash xml client socket.

Both codes are included below - they are both in the same folder on the web site and I am only trying to get them to connect.

Cheers

doc

THE PHP SOCKET SERVER (run on browser for the moment - daemon later when sorted!)
<?php
// set some variables
$host = "my ip address";
$port = 1234;
// don't timeout!
set_time_limit(0);
// create socket
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP) or die("Could not create socket\n");
// bind socket to port
$result = socket_bind($socket, $host, $port) or die("Could not bind to socket\n");
// start listening for connections
$result = socket_listen($socket, 5) or die("Could not set up socketlistener\n");
// accept incoming connections
// spawn another socket to handle communication
$spawn = socket_accept($socket) or die("Could not accept incomingconnection\n");
// read client input
$input = socket_read($spawn, 1024) or die("Could not read input\n");
$output = "Hello"."\0";
socket_write($spawn, $output, strlen ($output)) or die("Could not write output\n");
// close sockets
socket_close($spawn);
socket_close($socket);
?>

THE FLASH CLIENT SERVER (this is a one frame swf run on a simple web page)
<code>
mySocket = new XMLSocket();

mySocket.onConnect = function(success) {
if (success) {msgArea.htmlText += "<b>Server connection established!</b>";} else {
msgArea.htmlText += "<b>Server connection failed!</b>";}
}

mySocket.onClose = function() {
msgArea.htmlText += "<b>Server connection lost</b>";
}

mySocket.prototype.onData = function(msg) {
msgArea.htmlText += msg;
}

mySocket.connect("my ip address", 1234);
</code>
Mar 21 '07 #1
0 2216

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

5 posts views Thread by John Sheppard | last post: by
1 post views Thread by Bruce W.1 | last post: by
13 posts views Thread by coloradowebdev | last post: by
18 posts views Thread by nephish | last post: by
4 posts views Thread by carl_bevil | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.