如何在python3中将socket对象作为参数发送?

时间:2016-08-30 15:46:31

标签: multithreading sockets python-3.x

我想在线程中发送即将到来的请求的socket对象,以便我可以进一步与之通信。我是通过args=c发送的,但它无效。

import socket
import sys
import json
import threading

class server6:

    s = socket.socket()
    host = socket.gethostname()
    port = 123
    s.bind((host,port))
    s.listen(5)

    while True:
        c, addr = s.accept()
        print("Connection accepted from " + repr(addr[1]))
        print(str(c) + " :: " +str(addr))
        threading.Thread(target=threadMine, args=c).start()

    c.close()

    def threadMine(self, socket sock):
        #print("Thread"+ sock)

有人可以看一眼吗?

0 个答案:

没有答案