socket_object.Send Method

Sends a message to an open TCP connection.

...socket_object.Send( output_buffer, max_length )

Prerequisites

An active TCP connection must exist for the Socket.

The Socket Object must have been created by the tcpclient_object.Client method or the tcplistener_object.AcceptSocket method.

Parameters

output_buffer

The String value that is sent.

max_length

An optional value indicating the maximum number of data bytes to send. If omitted or zero, the entire output_buffer string is sent.

Remarks

If blocking is enabled, this method blocks if the output queue is full.

This method returns the number of bytes of data actually sent. If in blocking mode, the returned value is always equal to the number of bytes requested.  In non-blocking mode, the value may be less than the number of bytes requested.  In that case, you should re-issue the Send to output the remainder of the bytes.

If any network errors occur, this method throws an Exception.

Examples

Dim ep As New IPEndPoint("192.168.0.3", 1234)
Dim tc As New TcpClient(ep)
Dim sock As Socket
Dim output As String
Dim count As Integer
sock = tc.Client
...
count = sock.Send(output)

See Also

Networking Classes | socket_object.SendTo