我写了一段代码,测试没你说的那个问题
发送端:dim $atemp [4]
For $i=0 To 2
$atemp[$i] = string($i+1)
Next
$atemp[3] = "end"
TCPStartup ()
If @error = -1 Then Exit
For $i=0 To 3
$socket = TCPConnect (@IPAddress1,65431)
$send = TCPSend ($socket,$atemp[$i])
Next
TCPCloseSocket ($socket)
TCPShutdown ()
$temp = ""
For $i=0 To 3
$temp &= $atemp [$i]&@CRLF
Next
MsgBox (0,"发送端",$temp)
循环连续发送4个数组元素
接收端:Dim $atemp [4]
For $i=0 to 3
$atemp [$i] = 0
Next
TCPStartup ()
$socket = TCPListen (@IPAddress1,65431)
If @error = -1 Then Exit
$i=0
While 1
$connect = TCPAccept($socket)
$data = TCPRecv ($connect,1024)
ToolTip ($data&@crlf&$i)
If $data Then
$atemp[$i] = String($data)
$i += 1
If $data == "end" Then ExitLoop
EndIf
WEnd
TCPCloseSocket ($socket)
TCPShutdown ()
$temp = ""
For $i=0 To 3
$temp &= $atemp [$i]&@CRLF
Next
MsgBox (0,"接收端",$temp)
显示是正常的,并没有连在一起 |