Actionscript flex sockets and telnet
Posted
by MAC
on Stack Overflow
See other posts from Stack Overflow
or by MAC
Published on 2010-02-07T00:13:09Z
Indexed on
2010/05/10
0:08 UTC
Read the original article
Hit count: 170
I am trying to make a flex application where it gets data from a telnet connection and I am running into a weird problem.
To give a brief introduction, i want to read data from a process that exposes it through a socket. So if in the shell i type telnet localhost 8651
i receive the xml and then the connection is closed (I get the following Connection closed by foreign host.
)
Anyway i found a simple tutorial online for flex that essentially is a telnet client and one would expect it to work but everything follows Murphy's laws and nothing ever works!
Now i have messages being printed in every event handler and all places that i can think off. When i connect to the socket nothing happens, no event handler is triggered even the connect or close handler and if i do the following the socket.connected returns false! I get no errors, try catch raises no exception. I am at a loss as to whats going wrong?
socket.connect(serverURL, portNumber);
msg(socket.connected.toString());
Is there something about telnet that i do not know and its causing this to not work. Whats more interesting is why none of the events get fired.
Another interesting thing is that i have some python code that does the same thing and its able to get the xml back!
The following is the python code that works!
def getStats(host, port):
sock = socket.socket()
sock.connect((host, port))
res = sock.recv(1024*1024*1024, socket.MSG_WAITALL)
sock.close()
return statFunc(res)
So i ask you whats going wrong!!!!!! Is there some inherent problem with how flex handles sockets?
© Stack Overflow or respective owner