These are chat archives for IndySockets/Indy

1st
Feb 2018
milosdeymed
@milosdeymed
Feb 01 2018 09:03
Hello Indy people, I have strange problem using simple UDP (indy 10.6.2.5341 in Delphi 10.1). We have internet connected to mother board and device sending udp packets on different card (poe), we receive 320 packets/s, size 1190kB. And we only receive all packets when some continuous data flows trough the other (internet) interface - for example youtube video. if I stop the video, packet loss occures.
it seems to me as power saving mode or something like that on windows network layer. I do not know how exactly to troubleshoot this. wireshark shows continuous data flow.
milosdeymed
@milosdeymed
Feb 01 2018 13:23
We found solution, there was bad handling of multiple packets in buffer and somehow the thread reading packets probably gets to the CPU more frequently when there was traffic on network stack.
mercedwang
@mercedwang
Feb 01 2018 13:56
I have created a Linux console app by using TIdTCPServer in Delphi 10.2 Tokyo. I found that the action of setting the Active property of the component to False costs a long time (about half an hour) if the TCP server socket has one or more active connections. However the server socket can be closed quickly if it has no connection. What's the matter?
Matthijs ter Woord
@mterwoord
Feb 01 2018 13:56
probably its waiting for connectinos to be terminateds
mercedwang
@mercedwang
Feb 01 2018 13:58
@mterwoord However the same code runs very smoothly in Windows platform
mercedwang
@mercedwang
Feb 01 2018 14:07
@mterwoord In the OnExecute event handler, I only call AContext.Connection.IOHandler.ReadBytes() to read a byte from the client. After one or more connections have been established, those connections are terminated and TCP server socket are closed very quickly on Windows platform. if the Active property is set to False. However the main thread is frozen for al long time on Linux if the same operation is executed.
Matthijs ter Woord
@mterwoord
Feb 01 2018 14:09
no clue. never used indy on linux
well, that is, last 15 years..
mercedwang
@mercedwang
Feb 01 2018 14:15
@mterwoord Thanks anyway. How to report this problem to the Indy team?
Matthijs ter Woord
@mterwoord
Feb 01 2018 14:19
wait till someone responds here.. :)
Remy Lebeau
@rlebeau
Feb 01 2018 18:34
@mercedwang Indy uses blocking sockets, and infinite timeouts by default. When the server is deactivating, it closes all of its active sockets. Closing a socket in one thread is not guaranteed to unblock any blocked socket operations in other threads. It does on Windows, but it may not on all platforms. Try setting the IOHandler.ReadTimeout property to a short timeout and then handle any EIdReadTimedOut errors that occur. Or, before calling IOHandler.ReadBytes() (why not ReadByte()?), you can check IOHandler.InputBufferIsEmptyand if True then call IOHandler.CheckForDataOnSource() with a timeout, and skip ReadByte(s) until the IOHandler.InputBuffer actually has something available to read.
Kudzu
@czhower
Feb 01 2018 23:55
Iirc it should unblock when closed from other thread and its defined and expected behavior across platforms.