-
Content Count
1200 -
Joined
-
Last visited
-
Days Won
16
Everything posted by FPiette
-
I've found how to do it, more or less. This invokes TMessageManager class. There is only a SendMessage, no PostMessage. And there is no thread switch like in Windows messaging system. When you call SendMessage from a thread, the message subscriber (That is the message handler in Windows speaking) is directly called, that is it runs in the context of the sending thread. Actually there is neither a message queue which is logical since there is no PostMessage to queue a message. I can probably build the missing parts above the existing...
-
Yes and no... The OS already has a queue somewhere and FMUX is using it. The real problem is installing the custom message handler and posting message in that queue. FMUX already has HandleMessage and ProcessMessage but I have not found anything to post my own message and install a handler for it.
-
TWSocket problem on Delphi Intraweb
FPiette replied to Baxing's topic in ICS - Internet Component Suite
Here is a sample simple application: Delphi unit : unit WinHandleTestMain; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls; type TForm1 = class(TForm) CreateHWNDButton: TButton; Memo1: TMemo; PostMessageButton: TButton; DestroyHWNDButton: TButton; procedure CreateHWNDButtonClick(Sender: TObject); procedure DestroyHWNDButtonClick(Sender: TObject); procedure PostMessageButtonClick(Sender: TObject); private FWinHandle : HWND; procedure WndProc(var Msg: TMessage); public constructor Create(AOwner : TComponent); override; end; var Form1: TForm1; implementation {$R *.dfm} constructor TForm1.Create(AOwner: TComponent); begin inherited; FWinHandle := INVALID_HANDLE_VALUE; end; procedure TForm1.CreateHWNDButtonClick(Sender: TObject); begin if FWinHandle <> INVALID_HANDLE_VALUE then begin System.Classes.DeallocateHWnd(FWinHandle); FWinHandle := INVALID_HANDLE_VALUE; Memo1.Lines.Add('Window handle destroyed') end; FWinHandle := System.Classes.AllocateHwnd(WndProc); if FWinHandle = INVALID_HANDLE_VALUE then Memo1.Lines.Add('Error creating window handle') else Memo1.Lines.Add(Format('Window handle create %d', [FWinHandle])); end; procedure TForm1.DestroyHWNDButtonClick(Sender: TObject); begin if FWinHandle = INVALID_HANDLE_VALUE then Memo1.Lines.Add('Window handle not created yet') else begin System.Classes.DeallocateHWnd(FWinHandle); FWinHandle := INVALID_HANDLE_VALUE; Memo1.Lines.Add('Window handle destroyed') end; end; procedure TForm1.PostMessageButtonClick(Sender: TObject); begin if FWinHandle = INVALID_HANDLE_VALUE then Memo1.Lines.Add('Window handle not created') else if not PostMessage(FWinHandle, WM_USER, 1234, 5678) then Memo1.Lines.Add('PostMessage failed'); end; procedure TForm1.WndProc(var Msg: TMessage); begin Memo1.Lines.Add(Format('MSG=%d', [Msg.Msg])); end; end. The VCL form: object Form1: TForm1 Left = 0 Top = 0 Caption = 'Form1' ClientHeight = 289 ClientWidth = 382 Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -12 Font.Name = 'Segoe UI' Font.Style = [] PixelsPerInch = 96 TextHeight = 15 object CreateHWNDButton: TButton Left = 40 Top = 32 Width = 98 Height = 25 Caption = 'Create HWND' TabOrder = 0 OnClick = CreateHWNDButtonClick end object Memo1: TMemo Left = 40 Top = 72 Width = 297 Height = 185 Lines.Strings = ( 'Memo1') TabOrder = 1 end object PostMessageButton: TButton Left = 144 Top = 32 Width = 89 Height = 25 Caption = 'PostMessage' TabOrder = 2 OnClick = PostMessageButtonClick end object DestroyHWNDButton: TButton Left = 240 Top = 32 Width = 97 Height = 25 Caption = 'Destroy HWND' TabOrder = 3 OnClick = DestroyHWNDButtonClick end end -
Could you connect to the server using Windows command line utility telnet? Use this command line: telnet 195.29.150.117 25 BTW: 25 is standard SMTP port. If connection fails, then as Angus said, it is probably a firewall issue. If it succeed, it should also succeed with ICS.
-
What EXACT error message do you receive "connection is rejected" is not enough to tell. Which protocol are you using with Outlook? Outlook support several protocols. You have to look in Outlook mail account configuration. Make sure the account is configured as SMTP (mail send) and POP3 (Mail receive), or SMTPS/POP3S if SSL/TLS are used.
-
TWSocket problem on Delphi Intraweb
FPiette replied to Baxing's topic in ICS - Internet Component Suite
Can you confirm if IntraWeb has a message pump? To check, use Classes.AllocateHWnd to create a hidden window handle and attache a WndProc to it. Then from a button in your user interface, PostMessage a message to that window handle and from the WndProc, check if the message is received. First check in a normal VCL application to be sure you understand how it works. Then check within an IntraWeb application. -
Forget about D7! Try with recent Delphi version. Community Edition is free (Commercial use has some restrictions) and good.
-
TWSocket problem on Delphi Intraweb
FPiette replied to Baxing's topic in ICS - Internet Component Suite
Which IntraWeb version are you using ? -
TWSocket problem on Delphi Intraweb
FPiette replied to Baxing's topic in ICS - Internet Component Suite
I have zero knowledge about IntraWeb but I call tell you the requirement for ICS : You need a message pump to have the events triggered. If IntraWeb lacks a message pump, you may pump all your ICS stuff within a single thread having his own message pump. -
Not directly supported, but solutions exists. I don't recommend mixing VCL and FMX.
-
Should be: A := StrToInt ('$' + Result1);
-
This question is worth a specific publication. Please post it with a proper subject.
-
Long time ago, back in 2005, I implemented ICS for Linux. This was at the time of Kylix. The latest version was named "ICS for Kylix 3". Of course this code won't work with current Delphi but AFAIK the system calls I made for the message loop are still compatible with current Linux. The source code is still available from "ICS" page at my website http://www.overbyte.be. The message pump stuff has to be implemented to TIcsWndControl class which did not exist at Kylix 3 time. For the story : I implemented ICS for Kylix in the hope of having business in the Linux world. That was a total failure because at that time, all Linux user wanted everything without paying anything. If anyone (probably a group) has funds to sponsor development for Linux I'll be pleased to do it. That's how ICS for SSL was developed. The person having paid at least 100€ had immediate access to the code. The code was made free one year after ICS for SSL was ready.
-
wsocket send/receive compressed stream
FPiette replied to Lindawb's topic in ICS - Internet Component Suite
Those steps are correct. Remember the the receive side must know how many data to receive. You will likely receive several OnDataAvailable for significant amount of data. There is NEVER guaranteed relation between the number of Send() and the number of OnDataAvailable events. This is the biggest error many newbies are doing constantly. Be sure to read this documentation : http://wiki.overbyte.eu/wiki/index.php/Asynchronous_Paradigm -
Find which connection on WSocketThrdServer
FPiette replied to Lindawb's topic in ICS - Internet Component Suite
Your 3 connections have unique couple local IP and local port. That remains valid while the connection stay opened. On the next connection, the local IP will change. Thats' all you have on the network layer. You should probably design something in your communication protocol to identify a given connection. In HTTP implementation, it is common to use a cookie. That is small data sent by the server upon connection and sent back by the client with each subsequent send. Designing your own (reliable) protocol requires advanced knowledge about TCP/IP and communication protocol. -
> WSocket1.SendStr('<|START|>' + MemoryStreamToString(MyStream) + '<|END|>'); You should split this in 3 sends, you'll avoid the costly operation that concatenates the 3 string and the operation of converting the stream to string. WSocket1.SendStr(<|START|>'); WSocket1.Send(MyStream.Memory, MyStream.Size); WSocket1.SendStr( '<|END|>'); I urge you to carefully read those documentations, in that order: http://wiki.overbyte.eu/wiki/index.php/Asynchronous_Paradigm http://wiki.overbyte.eu/wiki/index.php/Sending_and_receiving_data
-
By the way, there are lots of serial component which are free and include full source code. Or commercial products with good documentation.
-
Using ReadByte you can read 24 bits from the UART, probably as 32 bits padded with zeros. You can build a 32 bits signed integer with that. Delphi compiler use 2's complement. You didn't answered my question: What does the string looks like ?
-
What looks the string like ? Does the component have a ReadByte function ?
-
Please show the code you are currently using.
-
You should explain what you want to do, what is the problem in your code and which part you don't know how to do.
-
Added to the repository.
-
I didn't. If you are interested, my application is there: https://github.com/fpiette/OvbImgOrganizer
-
WSocket1 send image as memory stream
FPiette replied to Lindawb's topic in ICS - Internet Component Suite
This is the way to send the content of the stream. But you have a problem for the receiver: how will the receiver know the length of the stream? It would be OK if this is the only thing sent for the whole session. Not a very good design. You should probably first send an integer with the stream size and then the stream content. The receiver will then first receive the length and then know how many byte it has to receive for the content. Also, you don't need to decode the JPEG before sending. Just load the file into the memory stream. The receiver will decode the JPEG. This will result in much less data sent thru the network. I don't know why you want to send the image using a bare socket. Bette to use a higher level component such as HTTP of FTP. Since you have not explained your whole problem, I cannot help you more. -
Is there any "standard protocol" for recovery from a failure in non atomic operations?
FPiette replied to roPopa's topic in Algorithms, Data Structures and Class Design
You could use a database transaction. Begin the transaction before printing and commit the transaction after printing. Roll the transaction back if printing failed. If a program crash occurs while printing or before the program crashes, the transaction will automatically rolled back.