# Path: log.py
# class __NullLogger:
#     def debug(self, msg=""):    pass
#     def warning(self, msg=""):  pass
#     def info(self, msg=""):     pass
#     def error(self, msg=""):    pass
#     def fatal(self, msg=""):    pass
# 
# Path: SigObject.py
# class SigObject(QObject):
#     def __init__(self):
# 
# Path: net/socktypes.py
# TCP_SERVER_BASE_TYPE = 0x00
# TCP_CLIENT_BASE_TYPE = 0x10
# UDP_SERVER_BASE_TYPE = 0x20
# UDP_CLIENT_BASE_TYPE = 0x30
# TCP_SERVER        = TCP_SERVER_BASE_TYPE | 0x01
# TCP_CLIENT_REMOTE = TCP_SERVER_BASE_TYPE | 0x02
# TCP_CLIENT_LOCAL  = TCP_CLIENT_BASE_TYPE | 0x10
# UDP_SERVER        = UDP_SERVER_BASE_TYPE | 0x00 # it's just like a sever
# UDP_CLIENT_REMOTE = UDP_SERVER_BASE_TYPE | 0x01
# UDP_CLIENT_LOCAL  = UDP_CLIENT_BASE_TYPE | 0x01


from log import logger
from SigObject import sigObject
from net import socktypes
import signals
import socket
import select
import socktypes
import threading
#-*- coding: utf-8 -*-

class SockClient():
    
    RECV_SIZE = 262144
    
    def __init__(self, parentId, sock, addr, sockType):
        self.parentId = parentId
        self._id = id(self)
        self.sockType = sockType
        self.conFlag = sockType == socktypes.TCP_CLIENT_REMOTE
        self.onlyStopSocket = False
        self.receiver = None
        if sock:
            self.sock = sock
        else:
            self.createSockByType(sockType)
            
        self.sock.setblocking(0)
        self.ip, self.port = addr[0:]
    
    def createSockByType(self, sockType):
        if sockType == socktypes.UDP_CLIENT_LOCAL:
            self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        elif sockType == socktypes.TCP_CLIENT_LOCAL:
            self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        else:

# Path: log.py
# class __NullLogger:
#     def debug(self, msg=""):    pass
#     def warning(self, msg=""):  pass
#     def info(self, msg=""):     pass
#     def error(self, msg=""):    pass
#     def fatal(self, msg=""):    pass
# 
# Path: SigObject.py
# class SigObject(QObject):
#     def __init__(self):
# 
# Path: net/socktypes.py
# TCP_SERVER_BASE_TYPE = 0x00
# TCP_CLIENT_BASE_TYPE = 0x10
# UDP_SERVER_BASE_TYPE = 0x20
# UDP_CLIENT_BASE_TYPE = 0x30
# TCP_SERVER        = TCP_SERVER_BASE_TYPE | 0x01
# TCP_CLIENT_REMOTE = TCP_SERVER_BASE_TYPE | 0x02
# TCP_CLIENT_LOCAL  = TCP_CLIENT_BASE_TYPE | 0x10
# UDP_SERVER        = UDP_SERVER_BASE_TYPE | 0x00 # it's just like a sever
# UDP_CLIENT_REMOTE = UDP_SERVER_BASE_TYPE | 0x01
# UDP_CLIENT_LOCAL  = UDP_CLIENT_BASE_TYPE | 0x01


# Path: net/SockClient.py
from log import logger
from SigObject import sigObject
from net import socktypes
import signals
import socket
import select
import socktypes
import threading

#-*- coding: utf-8 -*-

class SockClient():
    
    RECV_SIZE = 262144
    
    def __init__(self, parentId, sock, addr, sockType):
        self.parentId = parentId
        self._id = id(self)
        self.sockType = sockType
        self.conFlag = sockType == socktypes.TCP_CLIENT_REMOTE
        self.onlyStopSocket = False
        self.receiver = None
        if sock:
            self.sock = sock
        else:
            self.createSockByType(sockType)
            
        self.sock.setblocking(0)
        self.ip, self.port = addr[0:]
    
    def createSockByType(self, sockType):
        if sockType == socktypes.UDP_CLIENT_LOCAL:
            self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        elif sockType == socktypes.TCP_CLIENT_LOCAL:
            self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        else:

            logger.error("***** ERROR SOCKTYPE *****")