Foros del Web » Creando para Internet » Flash y Actionscript »

Socket sin conexion

Estas en el tema de Socket sin conexion en el foro de Flash y Actionscript en Foros del Web. Hola Gente, Queria hacer una consulta. Estoy haciendo un juego multiplayer con socket en flash CS3, con la forma de cliente-servidor. El cliene esta hecho ...
  #1 (permalink)  
Antiguo 02/04/2008, 00:23
 
Fecha de Ingreso: abril-2008
Mensajes: 1
Antigüedad: 16 años, 1 mes
Puntos: 0
Socket sin conexion

Hola Gente, Queria hacer una consulta. Estoy haciendo un juego multiplayer con socket en flash CS3, con la forma de cliente-servidor.
El cliene esta hecho en flash CS3, y el programa servidor esta programdo en C++ bajo SUse linux. Admeás, tengo instalado Xampp en linux.
El problema que tengo es que no me permite realizar la conexion desde el cliente al servidor. Estuve leyendo varios tutoriales e hice las
siguiente pruebas:

1) En el directorio raiz del servidor(httdocs) cree el archivo crossdomain.xml con el siguiente codigo

Código:
<?xml version="1.0" encoding="iso-8859-1"?>
	<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
	<cross-domain-policy>
		 <allow-access-from domain="*" to-ports="5555"/>
	</cross-domain-policy>
2) el codigo del cliente en flash CS3 lo hice de la siguiente manera

Código:
	var theSocket:XMLSocket = new XMLSocket();

	Security.loadPolicyFile("http://192.168.1.26/crossdomain.xml");
	// 192.168.1.26 es la IP del servidor

	theSocket.connect("192.168.1.126","5555");

	theSocket.onConnect = function(myStatus) {
    	if (myStatus) {
        	conn_txt.text = "connection successful";
    	} else {
        	conn_txt.text = "no connection made";
    	}
	};

	function sendData() {
	    var myXML:XML = new XML();
	    var mySend = myXML.createElement("thenode");
	    mySend.attributes.myData = "someData";
	    myXML.appendChild(mySend);
	    theSocket.send(myXML);
	}

	sendButton.onRelease = function() {
	    sendData();
	};

	theSocket.onData = function(msg:String):Void {
	    con_txt.text=msg;
	};
3) El codigo del programa servidor lo hice de la siguiente manera en c++

Código:
	#include "PracticalSocket.h"  // For Socket, ServerSocket, and SocketException
	#include <iostream>           // For cerr and cout
	#include <cstdlib>            // For atoi()

	using namespace std;

	const unsigned int RCVBUFSIZE = 32;    // Size of receive buffer

	void HandleTCPClient(TCPSocket *sock); // TCP client handling function

	int main(int argc, char *argv[]) {
	if (argc != 2) {                     // Test for correct number of arguments
	    cerr << "Usage: " << argv[0] << " <Server Port>" << endl;
	    exit(1);
	 }

	 unsigned short echoServPort = atoi(argv[1]);  // First arg: local port

	  try {
		  TCPServerSocket servSock(echoServPort);     // Server Socket object
  
	  	  for (;;) {   // Run forever
		  HandleTCPClient(servSock.accept());       // Wait for a client to connect
	    }
	  } catch (SocketException &e) {
	    cerr << e.what() << endl;
	    exit(1);
	  }
	  // NOT REACHED

	  return 0;
	}

	
	void HandleTCPClient(TCPSocket *sock) {
	  cout << "Handling client ";
	  try {
	    cout << sock->getForeignAddress() << ":";
	  } catch (SocketException e) {
	    cerr << "Unable to get foreign address" << endl;
	  }
	  try {
	    cout << sock->getForeignPort();
	  } catch (SocketException e) {
	    cerr << "Unable to get foreign port" << endl;
	  }
	  cout << endl;

	  // Send received string and receive again until the end of transmission
	  char echoBuffer[RCVBUFSIZE];
	  int recvMsgSize;
	  while ((recvMsgSize = sock->recv(echoBuffer, RCVBUFSIZE)) > 0) { // Zero means
                                                         // end of transmission
	    // Echo message back to client
	    sock->send(echoBuffer, recvMsgSize);
	  }
	  delete sock;
	}
El problema es que cuando me quiero conectar con el cliente siempre tengo problema con el connect de flash ya que no me conecta
con el servidor. Y siempre me muestra "no connection made" en el text box.
¿El problema puede ser que este en el croosdomain.xml?
Si yo abro el croosdomain.xml con algun navegador me aparece "Este archivo XML parece no tener información de estilo asociada. "
¿Puede ser que este sea el problema?¿Como lo puedo solucionar?

Desde ya muchas gracias
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 22:26.