Интересно, Delay(10) в данном коде значительно ускоряет программу. С чем это связано?
If CreateNetworkServer(Ip,Port)
PrintN("The server has been created!")
If CreateThread(@ReceiveTCPdata(),0) = 1
PrintN("The receive thread has been started!")
Else
PrintN("The receive thread failed!")
Delay(2000)
End
EndIf
Repeat
If TrySemaphore(SemaphoreIn) <> 0
LockMutex(MutexIn)
FirstElement(QueueIn())
TempFlag.i = QueueIn()\Flag
TCPclientID = QueueIn()\TCPclientID
TempData.s = QueueIn()\TCPdata
UnlockMutex(MutexIn)
DeleteElement(QueueIn())
Select TempFlag
Case 1;Новое подключение
connectMap(Str(TCPclientID))\Packet=""
PrintN("New connection: "+Str(TCPclientID))
Case 2;Дисконнект
PrintN("Disconnected: "+Str(TCPclientID))
DeleteMapElement(ConnectMap(),Str(TCPclientID))
EndSelect
EndIf
Delay(10)
Until Inkey() = Chr(27)
CloseNetworkServer(Ip)
Else
PrintN("The server creation failed!")
Delay(2000)
End
EndIf