WebUdpGetBindInfo Function

Action

Receives the IP address and the port to which the specified UDP socket is bound. If the socket has been bound by the optional parameters of the WebUdpCreate function, the function would simply return these values. If the port has not explicitly been specified, then the function would retrieve the value, which has been automatically set by the system during the first WebUdpSendTo function. If the socket is not bound to a specific IP address a value of “0.0.0.0” is returned. If the socket is not bound to a specifically port yet a value of 0 is returned.

Include file

WebAPI.bdh

Syntax

WebUdpGetBindInfo( in  hUdp  : number,
                   out sIp   : string,
                   out nPort : number ): boolean;

Return value

  • true if the bind information has been queried successfully

  • false otherwise

Parameter Description
hUdp Valid UDP handle, that has been created by WebUdpCreate.
sIp String that receives the IP address to which the specified socket is bound. “0.0.0.0” is returned if the socket is not bound to a specific IP address.
nPort Variable that receives the port number to which the specified socket is bound. If the socket is not bound yet a 0 is returned.

Example

dcltrans
  transaction TWeb
  var
    nUdp  : number;
    sBuf  : string;
    sIp   : string;
    nPort : number;
  begin
    WebUdpCreate(nUdp);
    WebUdpSendTo(nUdp, "10.5.2.103", 9998, "1234567890");
    WebUdpGetBindInfo(nUdp, sIp, nPort);
    print("bound to "+sIp+" : "+string(nPort));
    WebUdpRecvFrom(nUdp, sBuf, STRING_COMPLETE, sIp, nPort);
    print("got data from "+sIp+" : "+string(nPort));
    WebUdpClose(nUdp);    print(sBuf);
  end TWeb;