We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 09b50c7 commit 0f7e989Copy full SHA for 0f7e989
scripts/tcptest.lua
@@ -0,0 +1,28 @@
1
+--调用c#接口进行tcp调试
2
+ipStr = "180.97.80.55"
3
+port = 12415
4
+sendStr = "hello server"
5
+
6
+sys.taskInit(function ()
7
+ tcpClient = CS.System.Net.Sockets.TcpClient(ipStr, port)
8
+ stream = tcpClient:GetStream()
9
+ while true do
10
+ -- Send the message to the connected TcpServer.
11
+ stream:Write(sendStr, 0, #sendStr)
12
13
+ print("Sent:", sendStr)
14
15
+ sys.wait(100)
16
+ print("start recv", stream.CanRead)
17
18
+ local revT = {}
19
+ while stream.DataAvailable do
20
+ table.insert(revT,string.char(stream:ReadByte()))
21
+ end
22
+ local rev = table.concat(revT)
23
+ print("receive",rev,#rev)
24
25
+ -- Close everything.
26
+ stream:Close()
27
+ tcpClient:Close()
28
+end)
0 commit comments