Flash第1帧,action是:
function got (xml) {
s=xml.toString(); //接收0结尾的xml文本
trace(s); //显示
sock.send(s.toLowerCase()); //转成小写,发送
}
sock = new xmlsocket();
sock.onxml=got; //server数据到达句柄
sock.connect("localhost",1201); //连接本机1201端口
s = new string();
VB的winsock控件sock,localport为1201,用户击1次窗体,就发1次大写字母,随后收client相应小写字母:
Option Explicit
Dim xml(0 To 1) As Byte '许存结尾0
Dim s As String '全局量
Private Sub Form_Load()
Show
xml(0) = 65 '字母A
xml(1) = 0 '0结尾
sock.Listen '侦听
End Sub
Private Sub sock_ConnectionRequest(ByVal ID As Long) '响应Client的连接
sock.Close
sock.Accept ID
End Sub
Private Sub Form_Click() '响应窗体的单击
sock.SendData xml '发送
xml(0) = xml(0) + 1
If xml(0) = 68 Then xml(0) = 65 '循环ABC
End Sub
Private Sub sock_DataArrival(ByVal b As Long)
Dim s As String '局部量
sock.GetData s '接收
Me.Caption = s '显示
End Sub