Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
TCP servers have something called a "timeout value".
I want MaxScript's TCP server to have a timeout value.
https://docs.microsoft.com/en-us/dotnet/api/system.net.sockets.tcpclient.receivetimeout?view=net-6.0
Is there a way to set a timeout value for the following code?
dotNetIPAddress = (DotNetClass "System.Net.IPAddress").Parse "127.0.0.1"
tcpListener = DotNetObject "System.Net.Sockets.TcpListener" dotNetIPAddress 8888
tcpListener.Start()s
socket = tcpListener.AcceptSocket()
while true do
(
sendByteStream = DotNetObject "System.Byte[]" 10000
socket.Receive sendByteStream
encoding = DotnetClass "System.Text.UTF8Encoding"
msgReceived = trimright (encoding.UTF8.GetString(sendByteStream))
)
Solved! Go to Solution.