Jump to content

ChrisChuah

Members
  • Content Count

    108
  • Joined

  • Last visited

Everything posted by ChrisChuah

  1. ChrisChuah

    How to use a particular network interface to send out UDP data

    Thanks Remy I will try to use the BoundIP property on my testing. regards chris
  2. Hi Remy Yes. As i send a UDP packet to a 192.168.100.255, the IP address that returns to me is also 192.168.100.255 as well as a reply from other servers. Is there a function to say isBroadcastAddress(aIPAddress: string) that i can use so as to know its a broadcast address? Does Indy library has such function? regards chris
  3. ChrisChuah

    Access Violation when i free idUDPClient

    Hi I am trying to create a thread that will send out UDP message and when it receive the UDP message from the server, it will send a Reply as event back to the caller. I create the UDPClient in the Execute function and of course i would need to free it when the thread ends. But why do i get access violation when i free it? The call stack is --IdSocketHandle.CloseSocket. --IdSocketHandle.Destroy -- System.TObject.free; --IdUDPBase.CloseBinding --IdUDPBase.Destroy --IdUDPClient.Destroy -- System.TObject.Free --FUDP.Free; please help to guide me what is the best way to send out UDP message and wait for reply? Should i use UDPServer rather than UDPClient? === Code === procedure ilUDPClientThd.Execute; var l_port : UInt32; l_memStream : TMemoryStream; l_len : integer; l_buf : TIdBytes; l_ilUDPData : Tt_BootReqMsg; l_ip : string; l_ipBytes : array[0..15] of byte; FUDP: TIdUDPClient; begin { Place thread code here } l_ip := getOwnIP; if l_ip = '' then begin DoOnLog('Cannot find own IP address'); exit; end; FUDP := TIdUDPClient.Create(nil); FUDP.Host := FBroadcastIP; FUDP.Port := FBroadcastPort; // FUDP.Binding.Port := FBroadcastPort; try l_port := FBroadcastPort; l_memStream := TMemoryStream.create; l_buf := ToBytes('SOREQ', IndyTextEncoding_ASCII); l_memStream.Write(l_buf[0], 6); l_port := GStack.HostToNetwork(l_port); l_memStream.write(l_port, 4); getArrayBytes(l_ip, l_ipBytes); l_memStream.Write(l_ipBytes, SizeOf(l_ipBytes)); l_len := l_memStream.size; setLength(l_buf, l_len); l_memStream.position := 0; l_memStream.Read(l_buf[0], l_len ); l_memStream.Clear; try FUDP.ReceiveTimeout := 3000; FUDP.BroadcastEnabled := true; // FUDP.Active := true; FUDP.SendBuffer(l_buf); // FUDP.SendBuffer(l_buf[0], l_len); FMsg := 'Send To Address: ' + FUDP.Host + ' Port: ' + Inttostr(FUDP.Port) + ' using IP: ' + l_ip; Synchronize(WriteToLog); // l_len := FUDP.ReceiveBuffer(l_ilUDPData, sizeof(l_ilUDPData), FUDP.ReceiveTimeout); setLength(l_buf, sizeof(l_ilUDPData)); l_len := FUDP.ReceiveBuffer(l_buf); if l_len <= 0 then begin FMsg:='No Data received in UDP'; FRepliedClientIP := ''; FRepliedClientPort := 0; Synchronize(ReplyToClient); Synchronize(WriteToLog); end else begin l_ilUDPData.Port := GStack.NetworkToHost(l_ilUDPData.Port); FRepliedClientIP := getStringFromBytes(l_ilUDPData.hid); FRepliedClientPort := l_ilUDPData.port; Synchronize(ReplyToClient); end; except on E:Exception do begin FMsg := 'Error in Recv Data in UDP: ' + e.message; FRepliedClientIP := ''; FRepliedClientPort := 0; Synchronize(ReplyToClient); Synchronize(WriteToLog); end; end; l_memStream.Free; FUDP.Binding.Destroy; except on E:exception do begin FMsg := 'Exception in SoFind: ' + e.Message; FRepliedClientIP := ''; FRepliedClientPort := 0; Synchronize(ReplyToClient); Synchronize(WriteToLog); end; end; FUDP.Disconnect; FUDP.Free; <<==== Access violation when i tried to free UDP Client end;
  4. ChrisChuah

    Access Violation when i free idUDPClient

    Thanks Remy.
  5. Hi I have an existing component that communicates with a server via TCP. However, this component can only be used in delphi. When i call a function in this component, it will send out a TCP message. After some time, it will return back data and it will trigger an event back in the component. So, anytime i want to use this component, i can drop the component into the form. I can double click on the event and write codes to handle the result from the event. Now, if i want to make this component into a DLL for C sharp programmer to use How can i create events into the dll for C Sharp programmer to use? Is there any example that i can use or follow please help regards chris
  6. ChrisChuah

    Access Violation when i free idUDPClient

    Hi When i use the IdUDPClient inside the thread object, the idUDPClient does not get any messages back even though it can be seen from the Wireshark that the message was sent back. However, if i place the IdUDPClient on a Form, i am able to get the message. Something funny is that when i use the IdUDPClient on the Form to send out the message, the first response message header is SOREQ <== this header is request header Checking on the Wireshark, the server returned SORE I tried to initialise the l_buf to $0 before retrieving from idUDPClient. However, its only the first message sent that will be always SOREQ and the rest will be SORE And the IP address returned in the message should be 192.168.84.128 which indicate the server address itself. seems like the first message is the same message that i sent out. please advise regards chris ===== Code for IdUDPClient on Form ===== procedure TForm1.Button2Click(Sender: TObject); var l_port : UInt32; l_memStream : TMemoryStream; l_len : integer; l_buf, l_buf1 : TIdBytes; l_ilUDPData : Tt_BootReqMsg; l_ip : string; l_ipBytes : array[0..15] of byte; FMsg : string; FRepliedClientIP : string; FRepliedClientPort : Uint32; l_index : integer; begin l_ip := getOwnIP; if l_ip = '' then begin writeLog('Cannot find own IP address'); exit; end; IdUDPClient1.Host := '192.168.84.255'; IdUDPClient1.Port := 55510; IdUDPClient1.BoundPort := 55510; try // FUDP.Active := true; l_memStream := TMemoryStream.create; l_buf := ToBytes('SOREQ'#0, IndyTextEncoding_ASCII); l_memStream.Write(l_buf[0], 6); l_port := 55510; l_port := GStack.HostToNetwork(l_port); l_memStream.write(l_port, 4); getArrayBytes(l_ip, l_ipBytes); l_memStream.Write(l_ipBytes, SizeOf(l_ipBytes)); l_len := l_memStream.size; setLength(l_buf, l_len); l_memStream.position := 0; l_memStream.Read(l_buf[0], l_len ); l_memStream.Clear; try IdUDPClient1.ReceiveTimeout := 3000; IdUDPClient1.BroadcastEnabled := true; IdUDPClient1.SendBuffer(l_buf); FMsg := 'Send To Address: ' + IdUDPClient1.Host + ' Port: ' + Inttostr(IdUDPClient1.Port) + ' using IP: ' + l_ip; WriteLog(FMsg); setLength(l_buf, sizeOf(l_ilUDPData)); for l_index := 0 to length(l_buf) - 1 do. <== initialise the buffer but i still receive SOREQ only on 1st time. l_buf[l_index] := byte($0); l_len := IdUDPClient1.ReceiveBuffer(l_buf, 2000); if l_len <= 0 then begin FMsg:='No Data received in UDP'; FRepliedClientIP := ''; FRepliedClientPort := 0; WriteLog(FMsg); end else begin l_memStream.Clear; l_memStream.Position := 0; l_memStream.Write(l_buf[0], l_len); l_memStream.Position := 0; setlength(l_buf1, 6); l_memStream.Read(l_buf1[0], length(l_buf1)); WriteLog('Op Code: ' + getStringFromBytes(l_buf1)); l_memStream.Read(FRepliedClientPort, sizeof(FRepliedClientPort)); WriteLog('Port value: ' + Inttostr(FRepliedClientPort)); l_memStream.Read(l_ilUDPData.hid, sizeof(l_ilUDPData.hid)); FRepliedClientIP := getStringFromBytes(l_ilUDPData.hid); FRepliedClientPort := GStack.NetworkToHost(FRepliedClientPort); WriteLog('Replied. IP: ' + FRepliedClientIP + ' Port: ' + Inttostr(FRepliedClientPort)); end; except on E:Exception do begin FMsg := 'Error in Recv Data in UDP: ' + e.message; FRepliedClientIP := ''; FRepliedClientPort := 0; WriteLog(FMsg); end; end; l_memStream.Free; except on E:exception do begin FMsg := 'Exception in SoFind: ' + e.Message; FRepliedClientIP := ''; FRepliedClientPort := 0; WriteLog(FMsg); end; end; end; ==== End =====
  7. ChrisChuah

    Access Violation when i free idUDPClient

    Hi Remy Would like to ask why the UDPClient did not receive any data. Attached is the screen capture of the Wireshark. The first pic shows the server received the message sent from the delphi client The second pic shows the server sends out the SORE (response) message to the delphi client IP address. However, the client reported that there is no data received <27/5/2022 11:14:02 am> Send To Address: 192.168.84.255 Port: 55510 using IP: 192.168.84.129 <27/5/2022 11:14:05 am> IP: Port: 0 replied <27/5/2022 11:14:05 am> No Data received in UDP Did i do something not right? please advise regards chris
  8. ChrisChuah

    Access Violation when i free idUDPClient

    Thanks Remy The only problem that i have with strings in delphi is that I dont know if they are Windows widechar or UTF8 char or ansi value Edit1.text := 'MET'; ShowMe(Edit1.text); Function showMe(aValue : string); var l_value : string; begin l_value := aValue + 'A'; UDPClient.Write(l_value); end; So when the edit1 value is pass into ShowMe function, what is the length of l_value? As my server only accepts ANSI type of characters, the data sent may be Windows WideChar. Hence to be on the safe side, i would have to translate it to idBytes. What is the general rule on how you would send data when the server only accepts ANSI characters. Please advise regards chris BTW, After 20 years of using Delphi, i still remembered you were helping me last time when i was using Delphi 5, 6 in one of the forum. Now, its hard to find help for delphi.
  9. thank you very much for your advices. Guess i think i will try to use COM dll and see if C sharp can use it or not.
  10. Hi So sorry it seems like its calling DLL rather than using Delphi to create DLL isnt it? Its been a long time since i create a DLL but isnt there an export function or something like that? regards chris
  11. Hi Actually I want to use delphi to create a DLL with functions or procedures containing a callback. How can i create such functions in delphi so that the project can be compiled to a dll for C Sharp programmer to use Previously all DLL functions does not have function pointer or callback functions when i was using Delphi 6 era. Also my C sharp programmers said they cannot use COM because their program will be running in Docker for linux please advise regards chris
  12. Hi, is there such components for delphi to develop iOS and Android application to read the MRZ (Machine Readable Zone) and the NFC chip on passport based on MRTD (Machine Readable Travel Document) on passport? regards chris
  13. ChrisChuah

    Delphi component for MRZ and NFC reader for Passport

    Actually, its not easy to find components written for Delphi For example, component to read ePassport whereby it need to capture the image of the MRZ portion of the passport and then read the NFC chip from the passport. These are quite specialised components which you can find libraries for swift, java, c sharp etc. However, cant find for delphi.
  14. ChrisChuah

    Delphi component for MRZ and NFC reader for Passport

    Thanks but seems like that are not a lot of components for NFC for delphi. Sometimes i wonder should i continue to develop in Delphi or move on to other programming languages. sigh..
  15. ChrisChuah

    Indy 9.0.18 on Delphi 6. Where can i get 9.0.50?

    thank you very much. I will try out the indy 9 first as currently i am still using 9.0.18 somehow the idHTTP.Head is causing my thread to hang and my app also hang as well not sure why any ideas? regards chris
  16. ChrisChuah

    TBluetoothLE in Windows 10

    Hi, In my fmx application running in windows 32, when i call the TBluetoothLE.DiscoverDevices(4000), the function does not return any event back. When it is run on iOS application, the function will return the event back as EndDiscovery Why is this event is not called in Windows 32? Is there something that i forgot? ===== Code ======== procedure TForm1.Button1Click(Sender: TObject); begin Memo1.Lines.Clear; Memo1.Lines.Add('Scanning for devices'); BluetoothLE1.DiscoverDevices(4000); end; ==== End Code ====== Why isnt this function below not called in Windows 10? procedure TForm1.BluetoothLE1EndDiscoverDevices(const Sender: TObject; const ADeviceList: TBluetoothLEDeviceList);
  17. Hi In Delphi 10.4.1, when the Win64 program called WebBrowser1.Navigate("file://z:\filename.pdf") where z drive is a shared drive, it will display the pdf in the Browser. However, when i upgraded to 10.4.2, the same function will prompt for File Download. I also tested to navigate a C drive pdf document and it will also prompt the file download Please help ====== source ========= procedure TForm1.Button1Click(Sender: TObject); var l_filename : string; begin if OpenDialog1.Execute then begin l_filename := OpenDialog1.FileName; // l_filename := 'file://' + l_filename; WebBrowser1.Navigate(l_filename); end; end; ======= End ================ regards chris
  18. ChrisChuah

    Delphi 10.4.2 TWebBrowser navigate URL

    Hi So sorry for the late reply actually, its the problem with Adobe Acrobat with Internet Explorer. I have to uninstall and re-install Adobe Acrobat again. seems like that solve my problem. regards chris
  19. ChrisChuah

    Delphi 10.4.2 TWebBrowser navigate URL

    hi Previously it was chrome as a default but i set to Edge Browser. However, i could not find anything about download on file type in Edge Browser. something related to mime type? regards chris
  20. Hi Has anyone done this soap interface before? I am able to get the SOAP interface using this https://ove-osb.microsdc.us:9015/OPERA9OSB/opera/OWS_WS_51/Information?WSDL The WSDL Import will generate a Information.pas file. I tried to call the LovQueryRequest but it only contains the basic XML without the headers. Anyone knows what i should do in order to add the OGHeaders and SecurityHeaders to it? regards chris
  21. After update the latest patch for 10.4.1 with the new PA Server, I could not run the iOS simulator in debug mode. Usually, the prompt will appear to ask user to enter password for debugging but this time, it does not come out. anyone having this error? ======= Log from PA Server =============== >listen Process Control Server Started pid 1258 exe built Feb 27 2020 Error: file permissions do not allow debugging listen Process Control Server Started pid 1298 exe built Feb 27 2020 Error: file permissions do not allow debuggin ======= End of Log ============== regards Chris
  22. i did that but it still having the same error. if not, i wont be so frustrated over it. sigh Also when i start the PAServer for the first time, it did not prompt me for the password.. i wonder why I just made a video you Youtube on this error. hopefully the members can advise me on what the error is.
  23. hi when the new patch is released, the PAServer pkg is also shown on my Windows VM. So i dragged the PAServer pkg into my Mac OS to install it. After installation, i ran my app but it showed disconnected session. On the PAServer in my MacOS, it showed >list Process Control Server started pid 1647 exe built Feb 27 2020 Error: file permissions do not allow debugging. Just today, i saw another patch is released but my PA Server still does not allow iOS debugging. I am running Mojave instead of Catalina because Catalina does not allow the PAServer to run because it is in 32 bit. anyone can advise? regards chris
  24. ChrisChuah

    TSwitch to allow change?

    Hi Is there a function when there is switch event, to disallow the component from switching from off to on? In my function, when the user activate the OnSwitch event, i will prompt the user to turn off? if the user said no, then the switch should remain at On. However, now the switch will auto turn off even though i set the IsCheck to true any ideas? regards chris
  25. ChrisChuah

    TSwitch to allow change?

    Thank you very much. i will try this out. regards chris
×