Sockets with ActionScript 3.0!!!

Sockets used ones and known are of the most powerful tools of programming for Internet and little used. He is possivel that software talks between itself being in different machines. For example serving Web as the apache is in a machine while the server of data base is in another one. The exchange of information between the machines are made through a communication protocol, in the case of the Internet, the TCP/IP. The Apache machine, twirling, for example the PHP, can be connected in the BD and carry through consults or modify data. The exchange of information in the net is organized by the TCP/IP, but, before the data being changed, it is necessary to create the communication channel between the machines. This is possivel using Sockets. Practically all the programming languages of the present time have support and use sockets. In summary, one programs can receive and transmit messages in TCP/IP opening one socket, and later writing and reading given through socket open. Sockets allows that the communication between processes is independent of its physical localization and the particular characteristics of the used media, that is, does not depend on software, but yes of the used protocol (normally protocols TCP/IP). In summary, socket is a species of “programming function�? that allows to open connections to other computers of the net so that given messages or data are changed between the machines by means of a communication protocol.
ActionScript 3,0 brought amongst the new class, the class flash.net.Socket, that is, now the Flash can be connected to other devices saw sockets.

Let us see an example of the use of sockets with Action Script 3,0, this codigo only connects to the server in door 80:

[as]package {
import flash.display.Sprite;
import flash.events.*;
import flash.net.Socket;
import flash.util.trace;

public class test_sockets extends Sprite{
public var host:String = ‘http://127.0.0.1’;
public var port:uint = 80;

public function test_sockets(){
super(host,port);
var conn:Socket = new Socket();
conn.connect(host,port);
conn.addEventListener(EventType.CONNECT,connectListener);
}
public function connectListener(event:Event) {
trace(event.type); // output: connect
}
}
}
[/as]

Macromedia Flex 2.0 MXML and ActionScript Language Reference
http://livedocs.macromedia.com/labs/1/flex/langref/index.html

Um VNC em FLEX
http://www.ifbin.com/news/2005/11/flex-2-flashvnc-alpha-1-by-darron.html

Was this article helpful? feel free to make a donation and help keep the blog in the air
ActionScript 3.0

Leave a Reply