Mentalis.org Security Library documentation

VirtualSocket.SendTo Method (Byte[], Int32, Int32, SocketFlags, EndPoint)

Sends data to a specific endpoint, starting at the indicated location in the data.

[Visual Basic]
Overridable Overloads Public Function SendTo( _
   ByVal buffer As Byte(), _
   ByVal offset As Integer, _
   ByVal size As Integer, _
   ByVal socketFlags As SocketFlags, _
   ByVal remoteEP As EndPoint _
) As Integer
[C#]
public virtual int SendTo(
   byte[] buffer,
   int offset,
   int size,
   SocketFlags socketFlags,
   EndPoint remoteEP
);

Parameters

buffer
The data to be sent.
offset
The position in the data buffer to begin sending data.
size
The number of bytes to send.
socketFlags
A bitwise combination of the SocketFlags values.
remoteEP
The EndPoint representing the destination location for the data.

Return Value

The number of bytes sent.

Remarks

If you are using a connection-oriented protocol or a connected Socket using a connectionless protocol, remoteEP overrides the endpoint specified in RemoteEndPoint. If you are using an unconnected Socket with a connectionless protocol, this method sets the LocalEndPoint property of the current instance to a value determined by the protocol. You must subsequently receive data on the LocalEndPoint.

Note If you specify the DontRoute flag as the socketflags parameter, the data you are sending will not be routed. If you specify the OutOfBand flag as the socketflags parameter, only out-of-band (OOB) data is sent. If you set the Blocking property to true, and buffer space is not available within the underlying protocol, this method blocks. If you are using a message-oriented Socket, and the size of buffer is greater than the maximum message size of the underlying protocol, no data is sent and Socket will throw a SocketException. If you are using a connection-oriented Socket, remoteEp is ignored.

Exceptions

Exception TypeCondition
ArgumentNullExceptionbuffer is a null reference (Nothing in Visual Basic).
-or-
The remoteEP parameter is a null reference (Nothing).
ArgumentOutOfRangeExceptionThe offset or size parameter exceeds the size of buffer.
SocketExceptionAn operating system error occurs while accessing the socket.
ObjectDisposedExceptionThe VirtualSocket has been closed.

See Also

VirtualSocket Class | Org.Mentalis.Security.Ssl Namespace | VirtualSocket.SendTo Overload List