python socket 的 settimeout 不会爆出错误,并且会出现粘包的问题

代码是这样的 c的socket的连接,q是队列,数据接收到后会放入 q 给其他程序处理

具体问题就是这个settimeout会粘包,我发一次数据他三四次才拿的到


def recvTCPmsgs(q, c):  # 用于接收 服务端 发送的数据
    ind = 0
    while True:
        c.settimeout(10)
        # print(c.gettimeout())
        msg = c.recv(600000)
        print('-------')
        print('接收到的数据为:',len(msg))
        print('-------')
        q.put(msg)
        ind += 1
        print(ind)
        # try:
        #     # time.sleep(2)
        #     msg = c.recv(600000)  # try to receive 100 bytes
        #     # print('-------')
        #     c.settimeout(None)
        #     q.put(msg)
        # except:  # fail after 1 second of no activity
        #     print("没有数据了,关闭端口")
        #     q.put('没数据了')
        #     c.close()
        #     break