Topic Path: Symbol Reference > Classes > TIdSocketHandle Class > TIdSocketHandle Methods > SendTo Method
TIdSocketHandle.SendTo Method

Sends data using the socket handle to a specific remote connection.

procedure SendTo(
    const AIP: string; 
    const APort: Integer; 
    const ABuffer: TIdBytes; 
    const AIPVersion: TIdIPVersion = ID_DEFAULT_IP_VERSION
IP address to used for the remote endpoint.
Port number to use for the remote endpoint.
Values to be send using the socket handle.
IP address family for the datagram transmission. Default value is ID_DEFAULT_IP_VERSION

SendTo is a procedure used to write the data specified in ABuffer to the remote system indicated by AIP and APort using the socket handle for the connection. 

Send uses GStack to access the Send API for the protocol stack using the Handle for the connection, ABuffer, AIP, and APort as arguments. 

If you are using a connectionless protocol, you do not need to establish a default remote host with the Connect method prior to calling SendTo. You only need to do this if you intend to call the Send method. If you do call the Connect method prior to calling SendTo, the remote endpoint will override the specified PeerIP and PeerPort for that send operation only. You are also not required to call the Bind method, because the underlying service provider will assign the most appropriate local network address and port number. If you need to identify the assigned local network address and port number, you can use the IP and Port properties after the SendTo method successfully completes. 

Although intended for connectionless protocols, SendTo also works with connection-oriented protocols. If you are using a connection-oriented protocol, you must first establish a remote host connection by calling the Connect method or accept an incoming connection request using the Accept method. 

In either of these cases, SendTo will ignore the remoteEP parameter and only send data to the connected or default remote host. 

Send returns the total number of bytes sent over the socket connection. 

Use Send to write data to the current PeerIP and PeerPort using the socket handle for the connection. 

SendTo does not make any provision for sending only a portion of the data in ABuffer. The data in ABuffer is sent starting at offset 0 (zero).

Copyright 1993-2006, Chad Z. Hower (aka Kudzu) and the Indy Pit Crew. All rights reserved.
Post feedback to the Indy Docs Newsgroup.