-
Content Count
52 -
Joined
-
Last visited
-
Days Won
2
Posts posted by chmichael
-
-
2 hours ago, Angus Robertson said:Most ICS functions are async, not blocking, you missed IpLogClient.onLogProgEvent := onCliLogProgEvent; from snippets, and in the event you check IpLogClient.States[0] for logstateOK or something else if failed.
As is often discussed here, it is rarely necessary or useful to use ICS components in a thread, but if so you can not use application.processmessages since that is the main thread, you have to create the component within the thread Execute method, set the MultiThreaded property to true, and call the component ProcessMessages method instead.
Angus
Ok, i fixed the routine to work both on main and on a thread. It works correctly locally but remotely it always connect OK even if the "server/port" is closed. Any ideas ?
btw, doSocketRemoteClick has the same behavior.
function IsInternetPortOpenICS(const AIPAddress: AnsiString = ''; const APort: Word = 0; const ATimeOut: NativeUInt = INFINITE): Boolean; var IpLogClient: TIcsIpStrmLog; FThreadID, FTimeout: NativeUInt; begin Result := False; try FThreadID := GetCurrentThreadId; IpLogClient := TIcsIpStrmLog.Create(nil); IpLogClient.LogProtocol := logprotTcpClient; IpLogClient.RemoteHost := AIPAddress; IpLogClient.RemoteIpPort := APort.ToString; //IpLogClient.onLogProgEvent := Form9.onCliLogProgEvent; //IpLogClient.CheckPing := True; //IpLogClient.PingWaitSecs := 1; if FThreadID <> MainThreadID then IpLogClient.MultiThreaded := True; IpLogClient.StartLogging; FTimeout := 0; while FTimeout < ATimeout do begin if FThreadID = MainThreadID then Application.ProcessMessages else IpLogClient.ProcessMessages; Result := IpLogClient.States[0] = logstateOK; if Application.Terminated or Result then Break; Inc(FTimeout, 10); Sleep(10); end; IpLogClient.StopLogging; finally if Assigned(IpLogClient) and IpLogClient.AnyStateOK then IpLogClient.StopLogging; FreeAndNil(IpLogClient); end; end;
-
5 hours ago, Angus Robertson said:The simplest way is with the TIcsIpStrmLog component, look at the doSocketRemoteClick procedure in the OverbyteIcsSnippets sample, although you can ignore SSL.
Failing to open a normal TCP connection will timeout after about 30 to 40 seconds, you can not easily make this any shorter, and you can not re-use the socket until the connection attempt fails, even if you abort it earlier. If you need to check a lot of ports, either use multiple components running in parallel (no threads needed for hundreds) or use the ping feature of TIcsIpStrmLog to see if at least the IP address exists before checking the port.
Angus
Hello Angus,
How can i get the result ? (Is open or not) Do i have to use application.processmessages ? I'm going to use this routine in a thread.
Thank youfunction IsInternetPortOpenICS(const AIPAddress: AnsiString = ''; const APort: Word = 0; const ATimeOut: NativeUInt = INFINITE): Boolean; var IpLogClient: TIcsIpStrmLog; begin try IpLogClient := TIcsIpStrmLog.Create(nil); IpLogClient.MaxSockets := 1; IpLogClient.LogProtocol := logprotTcpClient ; IpLogClient.RemoteHost := AIPAddress; IpLogClient.RemoteIpPort := APort.ToString; IpLogClient.CheckPing := False; IpLogClient.StartLogging; Result := // Check if connected ??? IpLogClient.StopLogging; finally if Assigned(IpLogClient) and IpLogClient.AnyStateOK then IpLogClient.StopLogging; FreeAndNil(IpLogClient); end; end;
-
16 hours ago, Remy Lebeau said:A connect() timeout can be implemented by just using a non-blocking socket and close() the socket after the timeout elapses. If it uses a thread internally, that is just an implementation detail of the OS, but that shouldn't block the app from being able to move on.
Well I'm using the following code to do what you're saying but for some reason it doesn't always work! Eg. even if the server port is closed it will return "True".
-
Hello,
How can i check if a TCP port is open over Internet with timeout using ICS ?
Thank you -
19 hours ago, Rollo62 said:I have checked that but it doesn't check the RowPitch.
-
Hello,
Anyone knows how to copy the Bits from a ID3D11Texture2D which it has different RowPitch than Bitmap.Width * 4 ?
if FTexture.RowPitch = FBitmap.Width * 4 then
for I := 0 to FBitmap.Height - 1 do
Move(FTexture.pData[4 * FBitmap.Width * I], FBitmap.Scanline^, 4 * FBitmap.Width);
else
?????Thank you
-
8 hours ago, Renate Schaaf said:It won't work, unless the images are all of the same size. Changing the size would cause at least a partial re-initialization.
For streaming it's always the same
-
1 hour ago, Renate Schaaf said:Of course, no other app would be able to use this format.
Well if you use it for internal use or streaming purposes you don't care.
-
bme.AddFrame(bm, false); It took 53 milliseconds to encode a 8k image faster than turbo-jpeg and with lower size as you say.
Imagine using a TMemoryStream you can do whatever you want with the frames and i'll don't care about the expensive initialization.
I don't understand why it creates a 10s video instead of 1s ...
-
4 hours ago, Renate Schaaf said:This is why that makes no sense (quoted from https://cloudinary.com/guides/video-formats/h-264-video-encoding-how-it-works-benefits-and-9-best-practices)
"H.264 uses inter-frame compression, which compares information between multiple frames to find similarities, reducing the amount of data needed to be stored or transmitted. Predictive coding uses information from previous frames to predict the content of future frames, further reducing the amount of data required. These and other advanced techniques enable H.264 to deliver high-quality video at low bit rates. "
That goes to my first request " 1) Encode to Stream".
As far the compression HEIF actually uses H.265 compression but there is not any hardware acceleration in Delphi or at least haven't found any!
https://en.wikipedia.org/wiki/High_Efficiency_Image_File_FormatHEIF files containing HEVC-encoded images are also known as HEIC files. Such files require less storage space than the equivalent quality JPEG.[2][3]
Thank you -
1 hour ago, Renate Schaaf said:Do you mean to Jpeg or Png? A video-format would not make any sense for a single image.
NVidea-chips can apparently do that, but I don't know of any Windows-API which supports that.
If you want to encode to Png or Jpeg a bit faster than with TPngImage or TJpegImage use a TWicImage.
Look at this nice post on Stackoveflow for a way to set the compression quality for Jpeg using TWicImage:
https://stackoverflow.com/questions/42225924/twicimage-how-to-set-jpeg-compression-quality
I was hoping i could use H264/5 hardware encoder/decoder for a single image. It should be faster and smaller than turbo-jpeg.
-
Can you add:
1) Encode to Stream
2) Hardware encode only 1 image ?
Thank you -
Just curious, anyone tried Skia for resampling ?
-
Yeap, ReduceColors doesn't have this issue!
-
Did you find any solution ? I have the same problem!
-
9 hours ago, Angus Robertson said:Well Isn't IOCP faster for a lot of connections ?
-
Hello,
Any chance for IOCP support in the future ?
-
On 1/9/2023 at 12:20 PM, Fr0sT.Brutal said:start async
repeat
check if async finished
until timeout elapsed
The question is how to check it without using application.processmessages ?
-
-
https://deleted - visit website and win smartphone!
-
Thank you both guys!
-
4 hours ago, Angus Robertson said:ICS deliberately does not offer sync version of the low level Winsock functions, only high level protocols like HTTP and FTP.
There is a blocking version of DnsLookup, but no timeout is possible since the OS function waits up to 30 seconds or more for DNS servers to respond to queries, So you need to implement your own abort on timeout. Or use the TDnsQuery component
Angus
Where is the blocking function ?
Also wouldn't be nice to have a timeout for that ?
-
6 hours ago, FPiette said:If you are looking for that, you are probably on the wrong track using ICS. It is much better to design your application using asynchronous operation only.
Well the TSSLSmtpCli has blocking functions which they work nicely. eg, OpenSync; MailSync;
-
Hello,
Can somebody implement the Synced functions of WSocket.DnsLookup and also TWDNSQuery ? (with timeout too)
Thank you
TCP Port Check with timeout
in ICS - Internet Component Suite
Posted
Got it! Thanks!