目前,我的python服务器没有正确接受客户端...我真的很困惑,因为它适用于python TCP客户端。当我运行一个试图连接到python服务器的C ++应用程序时,Python服务器阻止接受并且不接受C ++客户端。
我编写了一个C#TCP服务器,这似乎接受了C ++客户端。
我是否缺少python和c ++之间的特殊内容?我的直觉告诉我它可能与套接字的配置方式有关? endianness可以在这里发挥作用吗?
我的Python客户端代码在这里:
lis2
C ++代码是:
def fn_connect(self,
ip,
port):
logging.debug("Connecting using {0}:{1} Address".format(ip, port))
self.__ip = ip
self.__port = int(port)
self.__tcp_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
self.__tcp_socket.bind((self.__ip, self.__port))
except:
logging.info(traceback.format_exc())
logging.info("Failed to bind socket")
return
_backlog = 255
self.__tcp_socket.listen(_backlog)
# Start threading
self.waiting_thread = threading.Thread(target = \
self._fn_wait_for_connections)
self.waiting_thread.daemon = True
self.waiting_thread.start()
def _fn_wait_for_connections(self):
self.__running_waiting = True
while(self.__running_waiting):
try:
print "GOT HERE?"
_client_socket, _address = self.__tcp_socket.accept()
print "DONE?"
except:
logging.error(traceback.format_exc())
break
_client_ip = _address[0]
_client_port = _address[1]