Actionscript 3 :: Listen To Sockets Using It?
Jan 26, 2010I was searching on google for it, I couldn't find it.
I would like to know how can I listen to sockets using actionscript 3
I was searching on google for it, I couldn't find it.
I would like to know how can I listen to sockets using actionscript 3
var s:Socket = new Socket( "127.0.0.1", 6667 );
s.writeUTFBytes( 'WEBIRC cgipass "cgiirc" this.is.testing.com 127.0.0.1' );
s.writeUTFBytes( "NICK DaBit
" );
[code]...
It works to a point, it pings out as if I never did PONG in response, but I never got the PING message which tells me I'm not listening in on the connection correctly. What do I need to do instead? Btw this is all I have, it's all on 1 frame.
Here is my Output thing:
Attemping to launch and connect to Player using URL C:Documents and SettingsDavidMy Documents est_socket.swf
[SWF] C:Documents and SettingsDavidMy Documents est_socket.swf - 3088 bytes after decompression
:127.0.0.1 NOTICE AUTH :*** Looking up your hostname...
[code]...
I am not any kind of network programming pro, but it happened that I have faced necessity to develop socket-server on php (no way for using Java) for flash multiplayer browser-game (standard features like locations, team battles, etc).
The main problem is that TCP is point-to-point protocol and it completely occupies given port.Of course it is possible to create some kind of queue, which will manage connections to the socket, but this solution doesn't seems to be the fittest one.
It seems to me that using interval of "fair" ports (from 2000 to 2200, for example) is more fitting solution, because one request may take a lot of time to execute and players won't be happy to wait in queue.
But how can I implement this "port inteval" strategy?The solutions that I see are:
launcing php-script per every port (he-he, 2 hundreds of launched scripts!);somehow forking the initial process to new processes (2 hundreds of processed? Not nice too), one for every port;additional while-loop, which listens all the ports (looks very bad);using threading or something like that (the problem is that php is single-threaded, as far as I know; pcntl?).But somehow I don't like any of them, or at least don't know how to implement them in the best possible way.
What is the best existing strategy to handle multiple requests from multiple users per time unit without delays, and how to implement this strategy in php? We have our own Debian-server, so it is possible to use any required php extensions.
For example, if we are trying to develop chat application, we need some sort of fixed (I mean persistent) connections for each user. For example, we have 80 users in chat, and then one of them posted a message, which server tries to handle and send to all other connected users, also putting an entry to the history file or something like that.
In this situation polling server for new messages every 10 seconds from each of 80 users is craziness, so the need in persistent connection gets obvious.But I don't know what is the best way to implement something like this, considering that not all requests are handled instanlty.
I was trying to write a stress tester for my own protocol when I stumbled up on this problem.Anytime I create more than 4 connections from one PC Flash denies to receive anymore messages from the server although I'm still able to connect, and write messages.
View 1 RepliesWhat WebSockets add to raw TCP connection?Why should I use WebSockets?I'll have only Flash clients, no need to support Javascript clients.
View 1 RepliesIs there a way I can communicate through sockets in flash mx? I'm really really interested in this domain..
View 2 RepliesI've begun playing with Flash and XML Socket Servers and I thought I started taking to it easy, but now I'm running into some problems and I'm a bit confused! I was able to connect and disconnect to a socket server I wrote and Unity but I seem to be having problems sending and/or recieveing data.I wrote a small amount of code to try it out:
var server:XMLSocket = new XMLSocket();
server.connect("66.194.238.241",10000);
server.onConnect = function(success:Boolean) {[code].....
It seems to be connecting fine but when I click and I try my send.
I am trying to do a "hello world" level test of FTP in Flex, but for three days now, I cannot overcome the issue with how to coerce flex into accepting my crossdomain policy - even for testing purposes.Here is my code: The exact error text follows.
[Code]...
I have two (+) systems on a local network running an AIR application that need to send/receive updated positions and other events between each other. I'm currently using an AIR-based socket server one of the instances. The AMF and strong typing works great. What doesn't, however, is the syncing between clients.
In my example below, clientA is trying to send an AMF packet to clientB. The SOCKET_DATA events fire off as expected on the server, in sync with the mouse, however the data that clientB receives very quickly gets out of sync and events are lost.
It's fine if an occasional event gets dropped, however I need to know the most recent SOCKET_DATA event has the latest data. Instead, it just contains increasingly older data.
Code Snippets:
clientA writeObject: (on MOUSE_MOVE to test large number of events)
protected function stage_mouseMoveHandler ( pEvent : MouseEvent ) : void
{
[code]....
So, we want to move out from Air (Adobe stopping support and really bad implementation for the sqlite api, among other things). I want to make 3 things:
Connect with a flash (not web) application to a local mysql database.
Connect with a falsh (not web) application to a remote mysql database.
Connect with a flash (web) application with a remote mysql database.
[Code]...
if you can connect with socket wit mysql server, why use a web server (for example with php) to connect like a inter connectioN? why not connnect directly? I have done this a lot of times, using AMFPHP for example, but wouldn't be faster going directly? In the case of accessing local machine, it will be a more simple deploy application that only require the flash application + mysql server, not need to also instal a web server.
I created a Socket and a ServerSocket objects in as3, then I connected the socket using the connect method by passing to it a host and a port. Also I made the ServerSocket object listening for incoming connection from socket other than the socket I've just created. When the ServerSocket detects a connection and start receiving data, the socket object is disconnected automatically. So I want to know how to keep the connection alive in the socket object..
View 1 RepliesI am currently building an XML Socket Server that I am running locally on my computer. My flash client I build as an executable that runs on your computer and connects to mine via port 9000. I want however, to be able to run the flash client as a .swf in a web page on my website. I have a security policy but I don't know if I am using it right. My server is extremely basic still, it has no admin controls or even authentication or anything, right now it just spits back what it is given essentially, while I test out things and stuff. I just don't know how to handle any cross browser stuff.
********************************************All my code works as is if the flash file is compiled as a .exe from any computer. I have tested that. It just doesn't work as a .swf in a web browser.********************************************The file currently is set to just have the user type in their name and then when they move their mouse, it shows up on all other clients with their names next it it. Basically testing a real time activity updates.Here is my code and other files:My config.xml file:
HTML Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<config>
[code]......
this question has been bugging me for a year. Basically I'm trying to replicate Club Penguin (multi-player game for kids who are their own penguin who play other penguins who are other kids online). So far Ive got it working: [URL]
but it creates a horrendous cache of XML as it simply sends and receives an xml file between players (poleing I believe). I want to convert this to a socket connection. However I really want to know: -do you need your own webserver (I have an old PC I can convert to one fine), but how do I set it up (php, Red5?) -the examples I have refer to old versions of Flah and sometimes use the (legendary Senoculars) class KeyObject.as So ~ I know what I want to do Ive got half way there anybody know the other half?
it may be a stupid question what i'm going to ask, but i'll ask anyway ... just had an idea... is there a way i can comunicate through sockets in flash mx?
View 2 Repliesi wanted to make a game in which you play head to head with other people.. but before i get ahead of myself here..how to establish a server which receives info from all connected flash movies , and then sends it out to all the ones witch i want to? basically i was thinking of making a chat thing 1st of all and then depending on how difficult it is move on to my game idea..
View 5 RepliesAs the title says, I would like to know if Flash 8 or any version of flash can access sockets.For instance like winsock does. Using an IP and a port to send packets? I've seen it can connect to databases, but I haven't seen anything with it working with sockets, for instance a P2P chat using only an IP and a port to send an receive messages.
View 1 Repliesi wanted to make a game in which you play head to head with other people.. but before i get ahead of myself here..Any tutorials on how to establish a server which receives info from all connected flash movies , and then sends it out to all the ones witch i want to?basically i was thinking of making a chat thing 1st of all and then depending on how difficult it is move on to my game idea..
View 5 RepliesI'm able to connect, able to send a message from HTML 5 to the AIR socket server and have the server see that there is an inbound message and even see that there are more or less bytes available based on the size of the message, but am unable to see the content of the message sent through. I'm just trying to send one-way text communication via sockets from HTML 5 to an AIR app. Why I can't see the actual content of the message? I'll attach my AS3/AIR (Flash Pro CS5) code and my HTML/JS code.
View 1 Repliesi'm trying to develop a multiplayer game in AS3, but i don't know how to use the sockets, how to set up my server, actually i don't know how to start, i want to build a peer to peer game, which will have a "room" to find players, it will be a cars game, i already have all the rest of the game, i just need to be able to make it multiplayer
View 3 RepliesI am building a really simple Chat server/client using PHP and Flex. I have followed many tutorials and have a working server in PHP and a working client in Flex, except that if I use the client on Windows I can't send any messages.When I send a message on my Mac it goes through to the server and gets sent to all the clients, including any Windows client I may have connected. The message will actually display on Windows clients as well, it's only when I try sending from Windows that it doesn't work.
I've tried adding a crossdomain.xml file served by a PHP script listening on the correct port, but none of the clients ever seem to ask for it, and if the client works on Mac I assumed it should work on Windows. By the way I'm exporting the project as an AIR file (dunno if that makes a difference).I can't find anything regarding this so I'm wondering if I'm being stupid somewhere or whether I need to takes some special measures for Windows clients?I have pasted my client code below.
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.events.MouseEvent;[code]......
I read about a project that enables the developer to program a HTML5 web sockets application that is compatible with older browsers by automatically falling back to using a flash method.
View 1 Repliesdoing a project where the deviceorientation-data from smartphones get transfered to a socketserver, and from there to a flash-application.Now creating a http-server with nodejs wasn't too hard, and connecting from a smartphone via browser and transfering the data with socket.io worked fine.The problem comes with flash, i couldn't manage to connect my flash application to the http-server running socket.io. I figured out when i run a node tcp-server connecting from flash is no problem, but i have no more session management and i can't connect from the browser anymore.
View 1 RepliesI have a program in c++ that sends a socket of 23723 bytes to a flash player in one "shot".The flash player sometimes receives two packets of size 17520 and 6203, and other times it receives a single packet of 23723.
EDIT: There does not seem to be a way to obtain the total number of bytes associated with the send data from flash. This would make it very difficult to build a loop to reconstruct the "broken" packet.I thought TCP was supposed to correctly recombine the packets and I am having difficulty recombining them myself.This is my receiving handler in flash:
var socket:Socket = new Socket();
socket.addEventListener(Event.CONNECT, socketConnectHandler);
socket.addEventListener(ProgressEvent.SOCKET_DATA, socketDataReceivedHandler);[code]...
will at times print 23723, and at other times, will print 17520 quickly followed by 6203. The total size are just examples and are subject to change for each send sockets. Also many sockets can be sent or received at the same time, so the split packets can be inter-mixed. In c++ I could determine what the total size of the sent data was, even if I did not receive the whole sent data yet.
I have created AS3 APP that works with [URL]..The application works fine on my desktop, but if i upload it on my webserver, the flash sockets does not work, it connects but i'm unable to send or receive data.
View 1 RepliesOn my network I have a couple of pc's all running a bespoke server which will return the username of the person logged in when queried.I have the following piece of code.
private function LoopAndList():void
{
var loopSocket:Socket;
var fourthOctet:Number = 6;
[code]....
Now when this runs it doesn't work as I first thought. The iterations go though. the fourthOctet value is decremented. But somethinjg strange happens. You will notice in the above code that I have a hardcoded IP address in the loop. I have put this there to ensure that there is always a valid connection. So am aware it will always be connecting to 192.168.0.4.
But the connection only happens on the last connect call.
The ouput is:
192.168.0.6
Connecting to 192.168.0.6
192.168.0.5
Connecting to 192.168.0.5
[code]....
I have a C++ application which sends images to a Flex/Air front-end via TCP sockets. All this data transfer occur in the same host, so the socket connects to a localhost server. The problem is that the Flex/Air takes a really long time to read the entire image from the socket. The server sends the image quite fast, but the Flex/Air reads this image in tiny parts. The whole image has about 300MB and the Flex/AIR reads only about 1KB each iteration. So the flex keeps calling the socket data callback, which is causing the application to slowdown.
Is there any synchronous sockets to use with flex, or some kind of socket which can read the entire data all at once? If sockets aren't the best choice, is there any other faster options? My socket class looks like this:
[Code]...
Sometimes flash-socket ignors data which is being sent by server. I dunna know exactly if it's server-side problem(data actually aint being sent) or flash.How does flash handle numerous of data packages comming from server ? I know that flash perform all actions in single thread, but what happen when flash recive a lot of packages at same time ? Does flash serialize incomming packages and then call ProgressEvent.SOCKET_DATA for each package or just ignore those packages which cant be handled runtime ?
View 5 RepliesI writing a small action game in actionscript and I'm adding some mulitplayer features. I am currently using xml sockets and a small java socket server I wrote.
But I am now pondering, would my game have connection problems when people try to use ? wouldn't they need to open the port I used in their firewall and configure port forwarding in their routers ?
I did a small test over port 8080 and some remote computers running my swf connection test, they got connected but the connection was lost right away... is that a "cross domain" issue (I didn't learn the subject yet) or should I check the firewall and etc on the remote computers ?
Also, I am pretty early in the process - should I consider switching to RTMP to avoid connectivity issues ? Do commercial sites with multilayer flash action games use sockets for the connection ? Does electroserver/pulse/etc.. use sockets under the hood or RTMP ?
I'm currently working on a project where I need to access multiple devices with differing IP addresses and Ports. I've defined "buttons" that will go to specific devices depending on the user input (sorry, hard to explain but I'm sure you'll get it). Everything works like a charm but I'd really like to see if there is a better way to code the following (maybe with an array) but I can't get it to work.
I will have up to 20 different devices so I'd like to streamline the code instead of having a bunch of "if" statements. As you can see, it's all the same just incrementing the TKsocket name.
[Code]...
How do i receive flash objects in java? I'm trying to create a multiplayer game, i've chosen sockets to handle this and Java as the server. So far i made myself a client/server already. And it works when sending as3 objects. but, not the way i want it! I made a class in AS3 and in Java that represents the object to be sent. AS3 Class 'Package'
[Code]...