UdpOpen
Valid for: CANoe DE • CANoe4SW DEFunction Syntax
dword UdpOpen( dword ipv4Address, dword port); // form 1dword UdpOpen( byte ipv6Address[], dword port); // form 2dword UdpOpen( IP_Endpoint localEndpoint); // form 3
Method Syntax
UdpSocket::Open( dword ipv4Address, dword port); // form 1UdpSocket::Open( byte ipv6Address[], dword port); // form 2UdpSocket::Open( IP_Endpoint localEndpoint ); // form 3
Description
Depending on the address type, the function creates either an IPv4 or IPv6 UDP socket for use in connectionless, datagram-oriented communications. All parameters may be zero. If the port parameter is non-zero, the socket is implicitly bound to the given port. Otherwise, the socket can be bound later on with IpBind or it will be automatically bound to a free port with UdpSendTo. Note: If an address is given but the port is zero, no implicit bind is performed. Please use IpBind after opening the socket in this case.Parameters
- ipv4Address: The numerical local IPv4 address to be used with the socket. If set to 0, then the socket is address unspecific (address wildcard). It then can be used for all adapters on any address.
- ipv6Address: The local IPv6 address in a 16 byte array. Like in the IPv4 address, an address wildcard can be retrieved using IpGetAddressAsArray(”::”, ipv6AddrArray).
- port: The port in host-byte order to be used with the socket. If set to 0, then the socket is port unspecific (port wildcard).
-
localEndpoint: Binds the socket to this local endpoint. IP Address can be 0, if the socket should not be bound to an address. Port number can be undefined, if a dynamic port number should be used.
Examples:
IP_Endpoint(192.168.1.1:4000)– Bind to address and portIP_Endpoint(0.0.0.0:4000)– Bind only to port for IPv4IP_Endpoint([::]:4000)– Bind only to port for IPv6IP_Endpoint(192.168.1.1)– Bind to address and choose a dynamic port
Return Values
- INVALID_SOCKET (~0): The function failed. Call IpGetLastError to get a more specific error code.
- Any other value: A valid socket handle identifying the created socket.