No BSD License  

Highlights from
atlSocket

from atlSocket by David Ganor
A TCP/IP client-side socket entity implemented as an ActiveX DLL.

tcp_send(tcp_client_h, buff, precision)
function tcp_send(tcp_client_h, buff, precision)
%
% TCP_SEND sends a vector to the server, through an open socket.
% Each element/number in the vector can be one of the following
% supported precisions: 'byte'/'uint8', 'word'/'uint16' or 'dword'/'uint32'.
% The function returns nothing.
%
% IMPORTANT: IT IS ASSUMED THAT THE SERVER IS A BIG-ENDIAN MACHINE,
% HENCE, EACH ELEMENT'S HEXADECIMAL BYTE-REPRESENTATION IS SWAPPED.
%
%   tcp_send(tcp_client_h, buff, precision)
%

% Author:       David Ganor, WAVION Ltd.
% Last Update:  09/2003
% Revisions:
%   1. Created.

%% Checking input arguments
if (nargin ~= 3)
    error('Wrong number of input arguments');
end
if ~isobject(tcp_client_h)
    error('1st input argument must be a handle to an ActiveX object');
end
if isempty(tcp_client_h)
    error('1st input argument cannot be empty');
end
if ~ischar(precision)
    error('3rd input argument must be a string');
end
if ((length(buff) ~= prod(size(buff))) | ~isreal(buff) | (sum(buff - floor(buff)) ~= 0))
    error('2nd input argumnet must be a vector of real integers');
end

%% Sending input with the correct ActiveX interface, acording to input's size
if (prod(size(buff) == 1) %% input is a literal
    result = invoke(tcp_client_h, 'sendliteral', buff, precision);
else
    result = invoke(tcp_client_h, 'sendarray', buff, precision);
end

%% Checking returned value
if (result ~= -1)
    error_str = tcp_geterror(tcp_client_h);
    if ~isempty(error_str)
        error_str = ['ActiveX object: ' error_str];
    else
        error_str = 'TCP''s sendbuf failed without any error reported inside ActiveX object';
    end
    error(error_str);
end

Contact us at files@mathworks.com