1 function sockfd = establishClientSocket(socketConfigurationFile)
 
    2 % ESTABLISHCLIENTSOCKET - Establishes the client connection to the socket
 
    4 %   
sockfd = establishClientSocket('socket.cfg') connect MATLAB to 
 
    5 %   the BCVTB. This 
function will read the file socket.cfg to get
 
    9 %   socket file descriptor. In case of 
error, 
sockfd will be negative.
 
   11 %   This 
function will also load the library libbcvtb unless it is
 
   16 %  2009-06-26 MWetter@lbl.gov: First version, based on code of 
 
   17 %             Charles Corbin, UC Boulder
 
   19 % Load library if it is not already loaded
 
   20 BCVTBLIB=getBCVTBLibName();
 
   24 if ~libisloaded(BCVTBLIB)    
 
   25   msg='Error. Failed to load BCVTB library.';
 
   26   ME = MException('BCVTB:ConnectError', ...
 
   34 % Establish the socket connection
 
   35 if and(libisloaded(BCVTBLIB), (status == 1))
 
   38   disp('Could not load library establishClientSocket.m');
 
loadlibrary(LIBBCVTB,... 'matlabSocket.h',... 'includepath', './..',... 'mfilename', 'bcvtb.m')%-------------------------------------------------------------------%Check if Simulink is installed on this system.If Simulink is%is not installed
 
function described below The Simulink Library Browser needs to know which libraries in your Blockset it should and what names to give them To provide this information
 
function sockfd will be a positive integer for the socket file descriptor In case of error
 
function if the BCVTB library can be loaded and if sockfd is not a negative then this function sends signal to the socket If sending a message to the socket was successful
 
int establishclientsocket(const char *const docname)
Establishes a connection to the socket. 
 
end Establish the socket connection if and(libisloaded(BCVTBLIB),(status==1)) sockfd
 
static void XMLCALL end(void *data, const char *el)
Call back functions that will be used by the expat xml parser. 
 
if(strcmp(os,'windows'))%have Windows LIBBCVTB
 
Load library if it is not already loaded BCVTBLIB
 
function[retVal, flaRea, simTimRea, dblValRea]
 
else disp('Could not load library establishClientSocket.m')
 
if ~libisloaded(BCVTBLIB) loadlibrary(BCVTBLIB