Jump to content

Mark-

Members
  • Content Count

    303
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by Mark-


  1. 1 hour ago, bazzer747 said:

    //Run the report
    fRepCompEnrolment.sctRepCustListt.Run;

    Then, unless I am more confused, fRepCompEnrolment is on the same form, in another form declared in a "uses" on the form, or global.

    And "CTRL" left clicking on fRepCompEnrolment, in the IDE does nothing?


  2. 38 minutes ago, bazzer747 said:

    A global search in all files doesn't show anything other than the form where I run the Ace Report from.  

    Then put a break point in the form button. I am confused how you know where the "report" is launched from and cannot find the "report" unit from the calling location.


  3. 1 minute ago, Angus Robertson said:

    In what way was my response unclear? 

     

    Angus

     

    Using UDP, how to bind the socket to a  NIC or other interface device?

     

    > For UDP client, TWSocket LocalAddr and LocalPort may be set but are usually left blank,...

     

    Does that bind the socket (UDP) to the NIC or whatever the interface device type?

     

    I am trying to make sure I understand, for what I am trying to accomplish, and I want to update the Wiki with more data.

     


  4. 4 minutes ago, Angus Robertson said:

    For UDP server, TWSocket Addr and Port are set for listening. 

     

    For UDP client, TWSocket LocalAddr and LocalPort may be set but are usually left blank, the remote address and port are specified in the SendTo method when sending data.

     

    Angus

     

    Thanks for the response.

     

    So, for a UDP server, setting the addr is the interface address and LocalAddr is ignored?

    For a UDP client, how to bind the socket to an interface device? Using LocalAddr?

     

    Mark

     

     


  5. Hello,

     

    The Wiki page https://wiki.overbyte.eu/wiki/index.php/TWSocket

     

    Addr    Client: The host to connect to. Server: The interface to listen on.

     

    LocalAddr The local address to which the socket is bound.

     

    Is this true for TCP and UDP?

     

    For a client, Addr is the remote (host) address and LocalAddr, if specified, is the interface to bind the socket.

    For a server, Addr specifies the interface to listen on so LocalAddr is not used.

     

    Mark

     


  6. 22 minutes ago, Remy Lebeau said:

    The error code is stored in the raised ESocketException in its ErrorCode property.

    Sounds like a bug that should be reported to the ICS author.

    Thank you Remy.

     

    This: WsocketErrorDesc(ESocketException(exceptObject).ErrorCode) works.

     

    image.png.3e584815c58176a47278586e6b90f5ec.png

     

    I am hoping Angus reads the post.


  7. Hello,

     

    Delphi 10.2.3, (VCL) current version of ICS (V9.4).

     

    Testing to verify I caught and handled the issue of the customer entering a bad IP address for binding. The IP address is formatted correctly, just not a valid IP address for any present interface.

    I was using the OnError callback. Call connect, onError is called but, "LastError" was zero.

     

    Switched to catching it as an exception try Connect except end; LastError is still zero.

     

    Looked in the source at

    procedure TCustomWSocket.BindSocket;
    ...
    if WSocket_Synchronized_bind(HSocket, PSockAddrIn(@LocalSockName)^, SockNamelen) <> 0 then begin
    

    and the correct error code 10049 (WSAEADDRNOTAVAIL) is present but, it is never assigned to LastError, that I could see.

     

    Perhaps there is something different I should be doing.

     

    Any ideas?

     

    Thanks,

     

    Mark

     


  8. 6 minutes ago, Angus Robertson said:

    After doing a couple of tests, it seems the SO_BSP_STATE API returns the local address allocated to the socket, usually 0.0.0.0, rather than the address chosen by Windows.

    Thank you Angus.


  9. 2 hours ago, Kas Ob. said:

    I forgot to mention important thing about that structure and its size.

     

    You can't and must not put it on the stack !, it will overflow and destroy/corrupt the stack, so it must be on the heap and must be zeroed before usage as best practice, because there is two addresses (pointing to two structures) will be filled by that API and it will put them right after the initial structure and fix the addresses.

    Thank you.

     

    Not being on the stack is the only difference I see at the moment.

    I will give it a go and post the result.

     


  10. 6 minutes ago, Angus Robertson said:

    Sorry, no time to debug this at the moment.

    No problem.

     

    I found this on SO.

     

    "... that illustrates that in fact SO_BSP_STATE requires a buffer more than sizeof(CSADDR_INFO), which is in direct contrast to the Microsoft published documentation: ...

     

    Still looking for a working example in any language.

     


  11. Well, the wall has been hit.

    Not sure what is going on.

     

    Using what I "think" should work ends with:

    image.png.2f70c58f2f29997277c500181d7b57b9.png

     

    Replacing

     

    add_info:CSADDR_INFO;

    with

    add_info:CSADDR_INFO2

    and no error.

     

    type
     SOCKET_ADDRESS = record
      lpSockaddr:PSOCKADDR;
      iSockaddrLength:integer;
    end;
    
    type
     CSADDR_INFO = record
      LocalAddr:SOCKET_ADDRESS;
      RemoteAddr:SOCKET_ADDRESS;
      iSocketType:Integer;
      iProtocol:Integer;
     end;
    
    type
     CSADDR_INFO2 = record
      space:array [0..127] of byte;
    end;
    
    procedure TForm3.FormDestroy(Sender: TObject);
    begin
     WSocket1.Abort;
    end;
    
    function GetLastSocketErrorMessage: string;
    var
     ErrorCode:integer;
     Buffer:array[0..255] of Char;
    begin
     ErrorCode := WSAGetLastError;
     if ErrorCode <> 0 then
      begin
       FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM or FORMAT_MESSAGE_IGNORE_INSERTS,
                     nil, ErrorCode, 0, Buffer, SizeOf(Buffer), nil );
       Result := Format('Socket Error %d: %s', [ErrorCode, StrPas(Buffer)]);
      end
     else
      Result := 'No socket error.';
    end;
    
    procedure TForm3.FormShow(Sender: TObject);
    var
     optLen:integer;
     add_info:CSADDR_INFO;
    begin
     WSocket1.Connect;
    
     OptLen:=SizeOf(add_info);
     FillChar(add_info,OptLen,#0);
    
     if WSocket_getsockopt(WSocket1.HSocket,
                           SOL_SOCKET,
                           SO_BSP_STATE,
                           @add_info,
                           OptLen) = SOCKET_ERROR then
      ShowMessage(GetLastSocketErrorMessage);

    Any ideas?

     

    Mark

     


  12. Hello,

     

    A computer with multiple networks interfaces. The "port" and "addr" are set. "LocalAddr" is not set. No SSL.

    "Connect" command is called.

    The question, how to determine the IP address of the network interface used.

     

    Cheers,

     

    Mark


  13. 3 minutes ago, Remy Lebeau said:

    Really? They all look the same to me... weird...

    I guess you are not comparing them.

     

    Not sure what you are trying to do Remy.

     

    I wrote in the first post, I wanted to use the same script names that TFontDialog displayed.

    The matrix I produced has the descriptions, the post you refer to does not have any descriptions used by TFontDialog.

    I had to create a few descriptions because TFontDialog did not show the font.

     

    Remy, I know you provide a lot of help on this forum and on other sites. And I have, many times, read your post and thought it was great.

    I am not sure you are helping in this thread.


  14. 7 minutes ago, Remy Lebeau said:

    Those are all the same values that @Kas Ob. showed you earlier, which Microsoft already documents in several places of MSDN.  So you didn't need to go to that effort.

    No, it is not the same.

     

×