Socket.Send Method (Byte, Int32, SocketFlags)
Assembly: System (in System.dll)
The number of bytes to send.
buffer is null.
size is less than 0 or exceeds the size of the buffer.
socketFlags is not a valid combination of values.
An operating system error occurs while accessing the socket. See the Remarks section for more information.
The Socket has been closed.
This overload requires a buffer that contains the data you want to send, the number of bytes you want to send, and a bitwise combination of any SocketFlags. If you specify the DontRoute flag as the socketflags parameter, the data you are sending will not be routed.
If you are using a connectionless protocol, you must call Connect before calling this method, or will throw a SocketException. If you are using a connection-oriented protocol, you must either use Connect to establish a remote host connection, or use Accept to accept an incoming connection.
If you are using a connectionless protocol and plan to send data to several different hosts, you should use the SendTo method. If you do not use the SendTo method, you will have to call the Connect method before each call to the method. You can use SendTo even after you have established a default remote host with Connect. You can also change the default remote host prior to calling by making another call to Connect.
With a connection-oriented protocol, Socket.SendTimeout. If the time-out value was exceeded, the call will throw a SocketException. In nonblocking mode, may complete successfully even if it sends less than the number of bytes you request. It is your application's responsibility to keep track of the number of bytes sent and to retry the operation until the application sends the requested number of bytes. There is also no guarantee that the data you send will appear on the network immediately. To increase network efficiency, the underlying system may delay transmission until a significant amount of outgoing data is collected. A successful completion of the method means that the underlying system has had room to buffer your data for a network send.will block until the requested number of bytes are sent, unless a time-out was set by using
You must ensure that the size does not exceed the maximum packet size of the underlying service provider. If it does, the datagram will not be sent and SocketException. If you receive a SocketException, use the SocketException.ErrorCode property to obtain the specific error code. After you have obtained this code, refer to the Windows Sockets version 2 API error code documentation in the MSDN library for a detailed description of the error.will throw a
The successful completion of a send does not indicate that the data was successfully delivered. If no buffer space is available within the transport system to hold the data to be transmitted, send will block unless the socket has been placed in nonblocking mode.
This member outputs trace information when you enable network tracing in your application. For more information, see Network Tracing in the .NET Framework.
Available since 1.1