【发布时间】:2018-07-29 07:09:05
【问题描述】:
我试图使用 pycurl 卷曲一个 tcp 服务器
class Detector():
def __init__(self, api_addr="tcp://localhost:8000"):
self.c = pycurl.Curl()
self.c.setopt(self.c.URL, api_addr)
def close_connection(self):
self.c.close()
def img_encode(self, img):
_, img_encoded = cv2.imencode('.jpg', img)
return img_encoded.tostring()
def detect(self, img):
encoded_msg = self.img_encode(img)
self.c.setopt(self.c.POSTFIELDS, encoded_msg)
return self.c.perform()
但它报告pycurl.error: (1, 'Protocol "tcp" not supported or disabled in libcurl') 有什么解决方案或者 curl tcp 服务器不合适?
【问题讨论】:
-
不,不要为此使用 curl。 Curl 旨在用于在 TCP 之上运行的特定标准协议,尤其是 HTTP。
-
@nos 感谢您的回答:)。本来打算通过终端 curl 到服务器的,我想这种情况下我只能使用 tcp 客户端套接字。