No BSD License  

Highlights from
atlSocket

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

tcp_close(tcp_client_h)
function tcp_close(tcp_client_h)
%
% TCP_CLOSE closes the open socket, which the supplied handle
% is associated with and releases the ActiveX object.
% The function returns nothing.
%
%   tcp_close(tcp_client_h)
%

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

%% Checking input arguments
if (nargin ~= 1)
    error('Wrong number of input arguments');
end
if ~isobject(tcp_client_h)
    error('Input argument must be a handle to an ActiveX object');
end
if isempty(tcp_client_h)
    error('Input argument cannot be empty');
end

%% Closing socket
res = invoke(tcp_client_h, 'close');
if (res ~= -1)
	error_str = tcp_geterror(tcp_client_h);
	if ~isempty(error_str)
        error(['ActiveX object: ' error_str]);
	else
        error('TCP''s close() failed without any error reported inside ActiveX object');
	end
end

%% Releasing memory
release(tcp_client_h);
clear tcp_client_h;

Contact us at files@mathworks.com