Skip to content
Snippets Groups Projects
Select Git revision
1 result Searching
An error occurred while fetching branches. Retry the search.

Win32SocketLecroy.cpp

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    Win32SocketLecroy.cpp 8.80 KiB
    //******************************************************************************************
    //
    //
    //		september 13, 2004 :  Source file for the communication in socket mode
    //
    //								with a Lecroy scope (avaiable for all models)
    //		
    //		author : X.Elattaoui
    //
    //		SocketLecroy.cpp: implementation of the SocketLecroy class.
    //
    //******************************************************************************************
    
    static int	hSocket;
    static int	sTimeout = 15;
    //static int	sWinsockInitFlag = FALSE;
    static char	sCurrentAddress[256];
    static int 	sConnectedFlag = false;
    const int	CMD_BUF_LEN	= 8192;
    static char sCommandBuffer[CMD_BUF_LEN];
    
    //- INCLUDE
    #include "SocketLecroy.h"
    
    //- init of the static instance
    SocketLecroy* SocketLecroy::SL_instance = 0;	//- ptr on the SocketLecroy instance
     
    SocketLecroy* SocketLecroy::get_instance()
    {
    	if( !SL_instance )
    		SL_instance = new SocketLecroy();
    
    	return SL_instance;
    }
    
    void SocketLecroy::delete_instance(SocketLecroy* SL_instance)
    {
    	if(SL_instance)
    	{
    		delete SL_instance ;
    		SL_instance = 0;
    	}
    }
    
    //- CTOR
    SocketLecroy::SocketLecroy()
    {
    	sConnectedFlag = false;
    }
    //- DTOR
    SocketLecroy::~SocketLecroy()
    {
       TCP_Disconnect();
    }
    
    //- Build the connection
    void SocketLecroy::TCP_Connect(char *ip_address) throw (lecroy::SocketException)
    {
    SOCKADDR_IN	serverAddr;
    int sockAddrSize = sizeof (SOCKADDR), result;
    const int resp = 1;
    fd_set wr_set = {1, {0}};
    TIMEVAL tval;
    unsigned long argp;
    char tmpStr[256];
    	
    	//- connection test
    	if (sConnectedFlag)
    		return;