您需要套接字连接:
var socket:Socket = new Socket();
socket.connect(host, port);
socket.addEventListener(Event.CONNECT, function(event:Event):void
{
socket.writeBytes(DATAS);
});
用于注释的测试代码的 UPD:
var _buffer:ByteArray = new ByteArray();
_buffer.writeByte(0xFF);
trace("_buffer=",ByteArrayUtil.getHexBytesString(_buffer));
var ou:ByteArray = new ByteArray();
ou.writeBytes(_buffer , 0 ,_buffer.length);
_buffer.clear();
trace("ou=\t", ByteArrayUtil.getHexBytesString(ou));
trace("_buffer=", ByteArrayUtil.getHexBytesString(_buffer));
public static function getHexBytesString(array:ByteArray, colons:Boolean=false, position:int = 0, len:int = 0):String {
var s:String = "";
if(!array)
return s;
if(len)
{
len += position;
len = Math.min(len, array.length);
}
else
len = array.length;
for (var i:int=position;i<len;i++) {
s+=("0"+array[i].toString(16)).substr(-2,2).toUpperCase();
if (colons && i<len-1) s+= "-";
}
return s;
}
输出:
_buffer= FF
ou= FF
_buffer=