Writes the specified number of 8-bit integers to the stream send buffer.
Namespace:
Quanser.Communications
Assembly:
Quanser.Communications (in Quanser.Communications.dll)
Syntax
Visual Basic (Declaration) |
---|
Public Function Send ( _
buffer As SByte() _
) As Integer |
C# |
---|
public int Send(
sbyte[] buffer
) |
Visual C++ |
---|
public:
int Send(
array<signed char>^ buffer
) |
JavaScript |
---|
function send(buffer); |
Parameters
- buffer
- Type: array<
System..::.SByte
>[]()[]
The buffer containing the values to write. The length of this buffer determines the
number of elements this method attempts to send. The number of elements
written may be less than the number of elements in the buffer, so be sure to check the return
value to see how many elements were actually written.
Return Value
The number of 8-bit integers written, which may be less than the number of elements in the
buffer
for non-blocking streams. If no 8-bit integers could be written to the stream buffer
and the method would block then
-ErrorCode.WouldBlock is returned for non-blocking
streams. If an error occurs then a
StreamException is thrown.
Remarks
Examples
This code snippet shows how to write up to five 8-bit integers to a stream.
C# | Copy Code |
---|
sbyte [] buffer = { 127, -128, 31, 41, 59 };
int numElementsWritten;
numElementsWritten = stream.Send(buffer);
if (numElementsWritten > 0) {
/* ... generate next data to send ... */
}
|
Visual Basic | Copy Code |
---|
Dim buffer() As SByte = {127, -128, 31, 41, 59}
Dim numElementsWritten As Integer
numElementsWritten = stream.Send(buffer)
If numElementsWritten > 0 Then
' ... generate next data to send ...
End If
|
Visual C++ | Copy Code |
---|
array<char>^ buffer = { 127, -128, 31, 41, 59 };
int numElementsWritten;
numElementsWritten = stream->Send(buffer);
if (numElementsWritten > 0) {
/* ... generate next data to send ... */
}
|
Exceptions
Exception | Condition |
---|
Quanser.Communications..::.StreamException |
If an error occurs then an exception is thrown. This situation
typically arises if an error has occurred in the underlying communication
channel, such as the connection being lost unexpectedly.
|
See Also