def __init__(self, XMLCFG):
        try:
            Msg = "ResponseHandler Init ..."
            PCA_GenLib.WriteLog(Msg, 9)

            PCA_ServerSocket.Acceptor.__init__(self, XMLCFG)
            Tag = "Handler"
            dll_file_name = PCA_XMLParser.GetXMLTagValue(XMLCFG, Tag)
            Msg = "dll_file_name=<%s> " % dll_file_name
            PCA_GenLib.WriteLog(Msg, 0)

            Script_File = PCA_DLL.DLL(dll_file_name)

            factory_function = "Parser"
            factory_component = Script_File.symbol(factory_function)
            self.parser = factory_component()
            factory_function = "Handler"
            factory_component = Script_File.symbol(factory_function)
            self.handler = factory_component()
            self.parser.setContentHandler(self.handler)

            Tag = "Routing"
            self.msg_routing = PCA_XMLParser.GetXMLTagValue(XMLCFG, Tag)
            Msg = "msg_routing = <%s> " % self.msg_routing
            PCA_GenLib.WriteLog(Msg, 0)

            Msg = "ResponseHandler Ok ..."
            PCA_GenLib.WriteLog(Msg, 9)
        except:
            Msg = "ResponseHandler error : <%s>,<%s> " % (sys.exc_type,
                                                          sys.exc_value)
            PCA_GenLib.WriteLog(Msg, 0)
            raise
Exemplo n.º 2
0
  def __init__(self,XMLCFG):
    try:
      Msg = "Writer Init "
      PCA_GenLib.WriteLog(Msg,9)
		
      #0                   1                   2                   3
      #0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
      #+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      #| Version       | Reserved      | Message Class | Message Type |
      #+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      #| Message Length                                               |
      #+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      #\ \
      #/ /

      self.SCCPMessage = PCA_SCCPMessage.Writer(XMLCFG)
      Tag = "ROUTING_CONTEXT"
      self.routing_context = string.atoi(PCA_XMLParser.GetXMLTagValue(XMLCFG,Tag))
      Tag = "OPC"
      self.opc = string.atoi(PCA_XMLParser.GetXMLTagValue(XMLCFG,Tag))
      Tag = "DPC"
      self.dpc = string.atoi(PCA_XMLParser.GetXMLTagValue(XMLCFG,Tag))

			
	
      Msg = "Writer OK"
      PCA_GenLib.WriteLog(Msg,9)
    except:
      Msg = "Writer Init Error : <%s>,<%s> " % (sys.exc_type,sys.exc_value)
      PCA_GenLib.WriteLog(Msg,0)	
      raise
Exemplo n.º 3
0
def DBXMLCFGInit(XMLCFG):
    try:
        global RequestMutex
        RequestMutex = thread.allocate_lock()

        global FileLineNo
        global FileNameSeqNo
        global DebugLogFileName
        global PrintDebugLogLevel
        global PrintDebug
        global FlushFile

        FileLineNo = 0
        PringDebug = 0
        DebugLogFileName = 'Debug.log'
        FileNameSeqNo = 1
        FileLineNo = 0
        FlushFile = 0

        ProgramName = os.path.basename(sys.argv[0])
        ################ Get Debug Log File Name #########################
        process_id = os.getpid()
        try:
            Tag = "DLOG"
            filename = PCA_XMLParser.GetXMLTagValue(XMLCFG, Tag)
            if (filename[-1] == "+"):

                DebugLogFileName = "%s.%05d" % (filename[:-1], process_id)
            else:
                DebugLogFileName = filename
        except:
            DebugLogFileName = "%s.%05d" % (ProgramName, process_id)

################ Get Debug Log Level #########################
        try:
            Tag = "DLVL"
            PrintDebugLogLevel = string.atoi(
                PCA_XMLParser.GetXMLTagValue(XMLCFG, Tag))
            #print 	"Your Debug Level = <%s>" % PrintDebugLogLevel
        except KeyError:
            PrintDebugLogLevel = 0

############### Flush Debug Log  #########################
        try:
            Tag = "DB_FLUSH"
            FlushFile = string.atoi(PCA_XMLParser.GetXMLTagValue(XMLCFG, Tag))
        except KeyError:
            FlushFile = 0

################ Print Message to stdin #########################
        try:
            Tag = "DB_PRINT"
            PrintDebug = string.atoi(PCA_XMLParser.GetXMLTagValue(XMLCFG, Tag))
        except KeyError:
            PrintDebug = 0
        OpenLog()
    except:
        Msg = "DBXMLCFGInit error <%s>,<%s>" % (sys.exc_type, sys.exc_value)
        print Msg
        raise
Exemplo n.º 4
0
    def __init__(self, XMLCFG):
        PCA_Parser.ContentHandler.__init__(self)
        self.Message = None
        self.M3UAMessage = PCA_M3UAMessage.Writer(XMLCFG)
        self.XMLCFG = XMLCFG
        Tag = "OPC"
        self.opc = struct.pack(
            "!i", string.atoi(PCA_XMLParser.GetXMLTagValue(XMLCFG, Tag)))
        Tag = "DPC"
        self.dpc = struct.pack(
            "!i", string.atoi(PCA_XMLParser.GetXMLTagValue(XMLCFG, Tag)))
        Tag = "NI"
        self.NI = struct.pack(
            "!B", string.atoi(PCA_XMLParser.GetXMLTagValue(XMLCFG, Tag)))

        Tag = "ROUTING_CONTEXT"
        self.routing_context = string.atoi(
            PCA_XMLParser.GetXMLTagValue(XMLCFG, Tag))

        version = PCA_M3UAParameters.version
        reserve = PCA_M3UAParameters.reserve
        message_class = PCA_M3UAParameters.Transfer_Messages
        message_type = PCA_M3UAParameters.DATA
        self.M3UA_header = version + reserve + message_class + message_type

        Tag = PCA_M3UAParameters.Routing_Context_Tag
        Length = struct.pack("!H", 8)
        Data = struct.pack("!i", self.routing_context)
        self.Routing_context = Tag + Length + Data
        self.Traffic_Type = "IN"
Exemplo n.º 5
0
    def __init__(self, XMLCFG):
        try:
            Msg = "Connector init ..."
            PCA_GenLib.WriteLog(Msg, 9)

            self.XMLCFG = XMLCFG
            Tag = "REMOTE_HOST"
            host = PCA_XMLParser.GetXMLTagValue(XMLCFG, Tag)

            Tag = "CONNECT_PORT"
            connect_port = PCA_XMLParser.GetXMLTagValue(XMLCFG, Tag)

            self.host = host
            self.connect_port = string.atoi(connect_port)

            Msg = "Host=<%s>,Port=<%s>" % (self.host, self.connect_port)
            PCA_GenLib.WriteLog(Msg, 7)

            Msg = "Call Socket..."
            PCA_GenLib.WriteLog(Msg, 7)
            # make a TCP/IP spocket object
            self.SocketDescriptor = socket.socket(socket.AF_INET,
                                                  socket.SOCK_STREAM)

            #  /* Set SO_REUSEADDR socket option to allow socket reuse */
            self.SocketDescriptor.setsockopt(socket.SOL_SOCKET,
                                             socket.SO_REUSEADDR, 1)
            Msg = "setsockopt..SO_REUSEADDR."
            PCA_GenLib.WriteLog(Msg, 8)

            #   /* Set SO_KEEPALIVE socket option */
            self.SocketDescriptor.setsockopt(socket.SOL_SOCKET,
                                             socket.SO_KEEPALIVE, 1)
            Msg = "setsockopt...SO_KEEPALIVE"
            PCA_GenLib.WriteLog(Msg, 8)

            try:

                Tag = "BIND_PORT"
                bind_port = PCA_XMLParser.GetXMLTagValue(XMLCFG, Tag)
                self.bind_port = string.atoi(bind_port)

                Msg = "bind port number = <%s>" % self.bind_port
                PCA_GenLib.WriteLog(Msg, 7)

                #self.SocketDescriptor.bind((self.host, self.bind_port))      # bind it to server port number
                #localhost = "127.0.0.1"
                self.SocketDescriptor.bind(
                    ('', self.bind_port))  # bind it to server port number
            except:
                Msg = "bind error..."
                PCA_GenLib.WriteLog(Msg, 8)

            Msg = "Connector OK."
            PCA_GenLib.WriteLog(Msg, 9)
        except:
            Msg = "Connector Initial error : <%s>,<%s> " % (sys.exc_type,
                                                            sys.exc_value)
            PCA_GenLib.WriteLog(Msg, 0)
            raise
Exemplo n.º 6
0
    def __init__(self, XMLCFG):
        try:
            Msg = "Writer Init "
            PCA_GenLib.WriteLog(Msg, 9)

            self.TCAPMessage = PCA_TCAPMessage.Writer(XMLCFG)

            Tag = "MESSAGE_TYPE"
            self.message_type = int(PCA_XMLParser.GetXMLTagValue(XMLCFG, Tag))

            Tag = "GT"
            self.GT = PCA_XMLParser.GetXMLTagValue(XMLCFG, Tag)
            Msg = "GT = <%s> " % self.GT

            PCA_GenLib.WriteLog(Msg, 1)
            Tag = "SC_ADDRESS"
            self.sc_address = PCA_XMLParser.GetXMLTagValue(XMLCFG, Tag)
            Msg = "sc_address = <%s> " % self.sc_address
            PCA_GenLib.WriteLog(Msg, 1)

            Tag = "FSG_GT"
            self.FSG_GT = PCA_XMLParser.GetXMLTagValue(XMLCFG, Tag)

            Msg = "Writer OK"
            PCA_GenLib.WriteLog(Msg, 9)
        except:
            Msg = "Writer Init Error : <%s>,<%s> " % (sys.exc_type,
                                                      sys.exc_value)
            PCA_GenLib.WriteLog(Msg, 0)
            raise
  def __init__(self,XMLCFG):		
    try:	
      Msg = "Prepare SCTP Server ..."
      PCA_GenLib.WriteLog(Msg,9)
      self.XMLCFG = XMLCFG	
      Tag = "LISTEN_HOST"
      host = PCA_XMLParser.GetXMLTagValue(XMLCFG,Tag)
      self.host = host		
			
      Tag = "LISTEN_PORT"
      port = PCA_XMLParser.GetXMLTagValue(XMLCFG,Tag)
      self.port = string.atoi(port)
			
      Msg = "Listen Host=<%s>,Port=<%s>" % (self.host,self.port)
      PCA_GenLib.WriteLog(Msg,1)
      self.SocketConnectionPool, self.ReadSet = [], []

      SocketDescriptor = sctp.sctpsocket_tcp(socket.AF_INET)
      if self.host == "any":
        SocketDescriptor.bind(("", self.port))
      else:
        SocketDescriptor.bind((self.host, self.port))
      SocketDescriptor.listen(5)
      self.SocketConnectionPool.append(SocketDescriptor) # add to main list to identify
      self.ReadSet.append(SocketDescriptor)    
    except :
      Msg = "SelectServer Initial error : <%s>,<%s> " % (sys.exc_type,sys.exc_value)
      PCA_GenLib.WriteLog(Msg,0)			
      raise
Exemplo n.º 8
0
    def __init__(self, XMLCFG):
        PCA_Parser.ContentHandler.__init__(self)
        self.Message = {}
        Tag = "NNN"
        self.sri_resp_NNN = PCA_XMLParser.GetXMLTagValue(XMLCFG, Tag)

        Tag = "SRI_RESP_IMSI"
        self.sri_resp_imsi = PCA_XMLParser.GetXMLTagValue(XMLCFG, Tag)
 def __init__(self,XMLCFG):
       PCA_Parser.ContentHandler.__init__(self)
       self.Message = {}
       Tag = "MT_FSM_ERROR"
       self.MT_FSM_ERROR = PCA_XMLParser.GetXMLTagValue(XMLCFG,Tag)
       Msg = "MT_FSM_ERROR = <%s> " % self.MT_FSM_ERROR
       PCA_GenLib.WriteLog(Msg,1) 
Exemplo n.º 10
0
    def __init__(self, XMLCFG):
        PCA_Parser.ContentHandler.__init__(self)
        self.Message = ""
        self.XMLCFG = XMLCFG

        Tag = "MESSAGE_TYPE"
        message_type = int(PCA_XMLParser.GetXMLTagValue(XMLCFG, Tag))
        self.message_type = struct.pack("!b", message_type)

        Tag = "GT"
        self.GT = PCA_XMLParser.GetXMLTagValue(XMLCFG, Tag)
        Msg = "GT = <%s> " % self.GT
        PCA_GenLib.WriteLog(Msg, 2)
        Tag = "SC_ADDRESS"
        self.sc_address = PCA_XMLParser.GetXMLTagValue(XMLCFG, Tag)
        Msg = "sc_address = <%s> " % self.sc_address
        PCA_GenLib.WriteLog(Msg, 2)

        self.SCCP_Message = {}
        self.Traffic_Type = "IN"
Exemplo n.º 11
0
  def MainTest(XMLCFG):
  	try:
		print 'Start MainTest ...'
		try:
			PCA_GenLib.DBXMLCFGInit(XMLCFG)		
			try:				
				Msg = "MainTest StartUp ... 2004/10/11 Version 1.0"
				PCA_GenLib.WriteLog(Msg,0)	
				
				
				
				Tag = "content_parser"
				dll_file_name = PCA_XMLParser.GetXMLTagValue(XMLCFG,Tag)
				Script_File = DLL(dll_file_name)
				factory_function="Parser"
				factory_component = Script_File.symbol(factory_function)
				parser = factory_component()
				
				Tag = "content_handler"
				dll_file_name = PCA_XMLParser.GetXMLTagValue(XMLCFG,Tag)
				Script_File = DLL(dll_file_name)
				factory_function="ContentHandler"
				factory_component = Script_File.symbol(factory_function)
				handler = factory_component()
					
				
			finally:
			
				PCA_GenLib.WriteLog(Msg,0)
			
		finally:
	
			PCA_GenLib.CloseLog()
 	except IOError:        
		print "MainTest IO error"
		print '< ',sys.exc_type,sys.exc_value,' >'

 	except:
   		print 'MainTest uncaught ! < ',sys.exc_type,sys.exc_value,' >'
   		import traceback
		traceback.print_exc()
Exemplo n.º 12
0
    def __init__(self, XMLCFG):
        try:
            Msg = "Connector init ..."
            PCA_GenLib.WriteLog(Msg, 9)
            self.XMLCFG = XMLCFG
            Tag = "REMOTE_HOST"
            host = PCA_XMLParser.GetXMLTagValue(XMLCFG, Tag)
            Tag = "CONNECT_PORT"
            connect_port = PCA_XMLParser.GetXMLTagValue(XMLCFG, Tag)

            self.host = host
            self.connect_port = string.atoi(connect_port)

            if _sctp.getconstant("IPPROTO_SCTP") != 132:
                Msg = "Connector init getconstant failed"
                PCA_GenLib.WriteLog(Msg, 0)

            Msg = "Call SCTP Socket..."
            PCA_GenLib.WriteLog(Msg, 7)
            # make a TCP/IP spocket object
            self.SocketDescriptor = sctp.sctpsocket_tcp(sctp.socket.AF_INET)

            self.saddr = (self.host, self.connect_port)
            Msg = "Host=<%s>,Port=<%s>" % (self.host, self.connect_port)
            PCA_GenLib.WriteLog(Msg, 7)
            self.SocketDescriptor.initparams.max_instreams = 3
            self.SocketDescriptor.initparams.num_ostreams = 3

            self.SocketDescriptor.events.clear()
            self.SocketDescriptor.events.data_io = 1

            Msg = "Connector OK."
            PCA_GenLib.WriteLog(Msg, 9)
        except:
            Msg = "Connector Initial error : <%s>,<%s> " % (sys.exc_type,
                                                            sys.exc_value)
            PCA_GenLib.WriteLog(Msg, 0)
            raise
Exemplo n.º 13
0
    def __init__(self, XMLCFG):
        try:
            Msg = "Writer Init "
            PCA_GenLib.WriteLog(Msg, 9)
            Tag = "SC_ADDRESS"
            self.sc_address = PCA_XMLParser.GetXMLTagValue(XMLCFG, Tag)
            Msg = "sc_address = <%s> " % self.sc_address
            PCA_GenLib.WriteLog(Msg, 1)

            Msg = "Writer OK"
            PCA_GenLib.WriteLog(Msg, 9)
        except:
            Msg = "Writer Init Error : <%s>,<%s> " % (sys.exc_type,
                                                      sys.exc_value)
            PCA_GenLib.WriteLog(Msg, 0)
            raise
Exemplo n.º 14
0
    def __init__(self, AcceptorConnection, XMLCFG):
        try:
            Msg = "ServerHandler Init ..."
            PCA_GenLib.WriteLog(Msg, 9)
            self.AcceptorConnection = AcceptorConnection
            self.ThreadID = id(AcceptorConnection)
            self.WriteSet = []
            self.WriteSet.append(
                self.AcceptorConnection)  # add to select inputs list
            self.ReadSet = []
            self.ReadSet.append(
                self.AcceptorConnection)  # add to select inputs list

            Tag = "ContentHandler"
            dll_file_name = PCA_XMLParser.GetXMLTagValue(XMLCFG, Tag)
            Msg = "%s=%s" % (Tag, dll_file_name)
            PCA_GenLib.WriteLog(Msg, 2)

            Script_File = PCA_DLL.DLL(dll_file_name)
            factory_function = "Parser"
            factory_component = Script_File.symbol(factory_function)
            self.parser = factory_component()

            Script_File = PCA_DLL.DLL(dll_file_name)
            factory_function = "Handler"
            factory_component = Script_File.symbol(factory_function)
            self.handler = factory_component()

            self.parser.setContentHandler(self.handler)

            Msg = "ServerHandler Ok ..."
            PCA_GenLib.WriteLog(Msg, 9)
        except:
            Msg = "ServerHandler error : <%s>,<%s> " % (sys.exc_type,
                                                        sys.exc_value)
            PCA_GenLib.WriteLog(Msg, 0)
            raise
Exemplo n.º 15
0
    def __init__(self, XMLCFG, cfg_file_name):
        try:
            PCA_ThreadServer.ThreadAcceptor.__init__(self, XMLCFG)

            self.XMLCFG = XMLCFG
            self.cfg_file_name = cfg_file_name

            PCA_ThreadLib.SetMainTerminateFlag("FALSE")
            PCA_ThreadLib.SetTerminateFlag("FALSE")

            Tag = "APPCFG"
            StartTag = Tag

            StartTag = "<%s>" % Tag
            EndTag = "</%s>" % Tag

            Tag = "SYSTEM_ID"
            self.UID = PCA_XMLParser.GetXMLTagValue(XMLCFG, Tag)
            Msg = "SYSTEM_ID  = <%s>" % (self.UID)
            PCA_GenLib.WriteLog(Msg, 1)

            Tag = "SYSTEM_TYPE"
            self.TYPE = PCA_XMLParser.GetXMLTagValue(XMLCFG, Tag)
            Msg = "SYSTEM_TYPE  = <%s>" % (self.TYPE)
            PCA_GenLib.WriteLog(Msg, 1)

            Tag = "PASSWD"
            self.PASSWD = PCA_XMLParser.GetXMLTagValue(XMLCFG, Tag)
            Msg = "PASSWD  = <%s>" % (self.PASSWD)
            PCA_GenLib.WriteLog(Msg, 1)

            (APPCFG,
             XMLCFG) = PCA_XMLParser.GetTagSection(XMLCFG, StartTag, EndTag)

            TaskList = []
            XMLConfiguration = PCA_XMLConfiguration.File_Reader(APPCFG, "TASK")

            ###################################################################
            #
            #    Read Configuration File to Task List
            #
            ###################################################################

            while 1:

                Task = XMLConfiguration.GetXMLConfiguration()

                if (Task == None):
                    #Msg = "Your Task  = <%s>" % (Task)
                    #PCA_GenLib.WriteLog(Msg,1)
                    break
                else:
                    Msg = "Your Task  = <%s>" % (Task)
                    PCA_GenLib.WriteLog(Msg, 4)
                    ########################################################
                    #
                    #  Connect to Multi Server
                    #
                    ########################################################

                    Tag = "CLIENT_SOCKET"
                    dll_file_name = PCA_XMLParser.GetXMLTagValue(
                        self.XMLCFG, Tag)
                    Msg = "%s=%s" % (Tag, dll_file_name)
                    PCA_GenLib.WriteLog(Msg, 1)

                    Script_File = PCA_DLL.DLL(dll_file_name)
                    factory_function = "Connector"
                    factory_component = Script_File.symbol(factory_function)
                    self.ClientConnector = factory_component(Task)

                    self.ClientConnector.connect()

                    thread.start_new(ResponseThread, (
                        self.SocketBuffer,
                        self.ClientConnector,
                        self.XMLCFG,
                    ))
                    time.sleep(0.5)
                    Tag = "SOURCD_ID"

                    Source_id = PCA_XMLParser.GetXMLTagValue(Task, Tag)
                    Msg = "%s=%s" % (Tag, Source_id)
                    PCA_GenLib.WriteLog(Msg, 1)

                    self.ClientConnectorList.append(
                        (self.ClientConnector, Source_id))
                    self.number_of_server_connection = self.number_of_server_connection + 1

            XMLConfiguration.Close()

            self.parser = PCA_SMPPParser.Parser()
            self.handler = PCA_SMPPParser.Handler()
            self.parser.setContentHandler(self.handler)

        except:
            Msg = "Gateway ProxyAcceptor Initial error : <%s>,<%s> " % (
                sys.exc_type, sys.exc_value)
            PCA_GenLib.WriteLog(Msg, 0)
            raise
Exemplo n.º 16
0
    def __init__(self, XMLCFG):
        try:
            Msg = "Acceptor Init ..."
            PCA_GenLib.WriteLog(Msg, 9)
            self.XMLCFG = XMLCFG

            Tag = "LISTEN_HOST"
            host = PCA_XMLParser.GetXMLTagValue(XMLCFG, Tag)
            self.host = host

            Tag = "LISTEN_PORT"
            port = PCA_XMLParser.GetXMLTagValue(XMLCFG, Tag)
            self.port = string.atoi(port)

            Msg = "Listen Host=<%s>,Port=<%s>" % (self.host, self.port)
            PCA_GenLib.WriteLog(Msg, 1)

            numPortSocks = 1  # number of ports for client connects
            # make main sockets for accepting new client requests
            self.SocketConnectionPool, self.ReadSet, self.WriteSet = [], [], []

            for i in range(numPortSocks):
                Msg = "Call Socket..."
                PCA_GenLib.WriteLog(Msg, 9)
                SocketDescriptor = socket.socket(
                    socket.AF_INET,
                    socket.SOCK_STREAM)  # make a TCP/IP spocket object

                # you should add "setsockopt(level, optname, value)"  here
                #  /* Set SO_REUSEADDR socket option to allow socket reuse */
                SocketDescriptor.setsockopt(socket.SOL_SOCKET,
                                            socket.SO_REUSEADDR, 1)
                Msg = "setsockopt..SO_REUSEADDR."
                PCA_GenLib.WriteLog(Msg, 9)

                #   /* Set SO_KEEPALIVE socket option */
                SocketDescriptor.setsockopt(socket.SOL_SOCKET,
                                            socket.SO_KEEPALIVE, 1)
                Msg = "setsockopt...SO_KEEPALIVE"
                PCA_GenLib.WriteLog(Msg, 9)

                SocketDescriptor.bind(
                    ('', self.port))  # bind it to server port number

                Msg = "setsockopt..bind port = <%s>." % self.port
                PCA_GenLib.WriteLog(Msg, 0)

                SocketDescriptor.listen(5)  # listen, allow 5 pending connects

                Msg = "setsockopt..Listen.SocketFD=<%s>" % (SocketDescriptor)
                PCA_GenLib.WriteLog(Msg, 9)

                self.SocketConnectionPool.append(
                    SocketDescriptor)  # add to main list to identify
                self.ReadSet.append(
                    SocketDescriptor)  # add to select inputs list
                self.WriteSet.append(
                    SocketDescriptor)  # add to select output list

            Msg = "Acceptor Initial Ok "
            PCA_GenLib.WriteLog(Msg, 9)
        except:
            Msg = "Acceptor Initial error : <%s>,<%s> " % (sys.exc_type,
                                                           sys.exc_value)
            PCA_GenLib.WriteLog(Msg, 0)
            raise
 def __init__(self,XMLCFG):    
     try:    
         Msg = "PCA_SMPPClientSocket init ..."
         PCA_GenLib.WriteLog(Msg,9)
        
         
         Msg = "Connector init ..."
         PCA_GenLib.WriteLog(Msg,1)
         
         self.parser = PCA_SMPPParser.Parser()
         self.handler = PCA_SMPPParser.Handler()
         self.parser.setContentHandler(self.handler)
        
         self.XMLCFG = XMLCFG            
         Tag = "REMOTE_HOST"
         host = PCA_XMLParser.GetXMLTagValue(XMLCFG,Tag)
         
         Tag = "CONNECT_PORT"
         connect_port = PCA_XMLParser.GetXMLTagValue(XMLCFG,Tag)
         
         self.host = host
         self.connect_port = string.atoi(connect_port)
         
         Msg = "Host=<%s>,Port=<%s>" % (self.host,self.connect_port)
         PCA_GenLib.WriteLog(Msg,7)
         
         
         Msg = "Call Socket..."
         PCA_GenLib.WriteLog(Msg,7)
         # make a TCP/IP spocket object
         self.SocketDescriptor = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
         
         
         #  /* Set SO_REUSEADDR socket option to allow socket reuse */
         self.SocketDescriptor.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
         Msg = "setsockopt..SO_REUSEADDR."
         PCA_GenLib.WriteLog(Msg,8)
         
         #   /* Set SO_KEEPALIVE socket option */
         self.SocketDescriptor.setsockopt( socket.SOL_SOCKET, socket.SO_KEEPALIVE,1 )
         Msg = "setsockopt...SO_KEEPALIVE"
         PCA_GenLib.WriteLog(Msg,8)
             
         try:                
             
             Tag = "BIND_PORT"
             bind_port = PCA_XMLParser.GetXMLTagValue(XMLCFG,Tag)
             self.bind_port = string.atoi(bind_port)
             
             Msg = "bind port number = <%s>" %  self.bind_port
             PCA_GenLib.WriteLog(Msg,7)
             
             self.SocketDescriptor.bind(('', self.bind_port))      # bind it to server port number
         except:
             Msg = "bind error..."
             PCA_GenLib.WriteLog(Msg,8)       
              
         
         Tag = "SYSTEM_ID"
         self.UID = PCA_XMLParser.GetXMLTagValue(XMLCFG,Tag)
         
         Tag = "SYSTEM_TYPE"
         self.TYPE = PCA_XMLParser.GetXMLTagValue(XMLCFG,Tag)
          
         Tag = "PASSWD"
         self.PASSWD = PCA_XMLParser.GetXMLTagValue(XMLCFG,Tag)
         
         Tag = "SOURCD_ID"
         self.SOURCD_ID = PCA_XMLParser.GetXMLTagValue(XMLCFG,Tag)
         
         
         
         Msg = "Connector OK."
         PCA_GenLib.WriteLog(Msg,9)                    
                 
                 
         Msg = "PCA_SMPPClientSocket OK."
         PCA_GenLib.WriteLog(Msg,9)
     except :
         Msg = "PCA_SMPPClientSocket Initial error : <%s>,<%s> " % (sys.exc_type,sys.exc_value)
         PCA_GenLib.WriteLog(Msg,0) 
         raise