actionscript3 air3.2 發送udp消息

air3.2發送udp的方法: 

在屬性屬性窗口中把目標設置爲:AIR  3.2 For Desktop

import flash.utils.ByteArray;
import flash.net.DatagramSocket;
var udpSocket:DatagramSocket  = new DatagramSocket();
var bytes:ByteArray = new ByteArray();
bytes.writeUTFBytes("test");
udpSocket.send(bytes, 0, 0, "127.0.0.1", 8888);

把“127.0.0.1"設置成目標ip,8888設置成目標端口就能發送了。

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章