No BSD License
-
tcp_close(tcp_client_h)
% TCP_CLOSE closes the open socket, which the supplied handle
-
tcp_connect(ip_address, port_...
% TCP_CONNECT instances an ActiveX object from atlSocket DLL,
-
tcp_geterror(tcp_client_h)
% TCP_GETERROR returns a string, containg the last error
-
tcp_getserveripaddress(tcp_cl...
% TCP_GETSERVERIPADDRESS returns a string containing the server's
-
tcp_getserverportnum(tcp_clie...
% TCP_GETSERVERIPADDRESS returns the TCP port number, on the server,
-
tcp_getsocketerrorcode(tcp_cl...
% TCP_GETSOCKETERRORCODE returns the last error code, that the underlying
-
tcp_recv(tcp_client_h, vec_le...
% TCP_RECV reads a vector from an open socket.
-
tcp_send(tcp_client_h, buff, ...
% TCP_SEND sends a vector to the server, through an open socket.
-
View all files
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