Skip to main content
Open topic with navigation

UdpSend

CAPL Functions » TCP/IP API » UdpSend Valid for: CANoe DE • CANoe4SW DE

Function Syntax

  • long UdpSend( dword socket, char buffer[], dword size); // form 1
  • long UdpSend( dword socket, struct data, dword size); // form 2
  • long UdpSend( dword socket, byte buffer[], dword size); // form 3

Method Syntax

  • long socket.Send(char buffer[], dword size); // form 1
  • long socket.Send(struct data, dword size); // form 2
  • long socket.Send(byte buffer[], dword size); // form 3

Description

The function sends data on a connected UDP socket. It is necessary to connect the socket with UdpConnect before calling this function.

Parameters

  • socket: The socket handle.
  • buffer: The buffer containing the data to be sent.
  • data: The struct containing the data to be sent.
  • size: The size of the data to be sent.

Return Values

  • 0: The function completed successfully.
  • WSA_INVALID_PARAMETER (87): The specified socket was invalid.
  • SOCKET_ERROR (-1): The function failed. Call IpGetLastSocketError to get a more specific error code.

Example

variables
{
  UdpSocket gSocket;
}

on start
{
  gSocket = UdpSocket::Open( IP_Endpoint(0.0.0.0:0) );
  gSocket.Connect(ip_Endpoint(192.168.1.3:40002));
  gSocket.Send( "Request", 7 );
}