如何与插座保持联系

发布于 2025-02-01 12:25:13 字数 759 浏览 2 评论 0原文

我需要做一个套接字服务(网关)才能从汽车跟踪器(JIMI VL02)接收数据包。

问题是:我不知道如何与跟踪器保持对照。

我(对于其他类型的汽车跟踪器)所做的最古老的服务是在收到包裹后退出的连接,如下面的示例。

localip = ''
port = 5005
bufferSize = 1024
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR,1)
server.bind((localip, port))
server.listen()

while True:
    client, adress = server.accept()  
    main(client, adress) 

def main():
  .
  .
  .
 client.close()   

在功能主管中,我用包装进行了整个必要的过程,然后代码关闭了Conection,以从其他或同一跟踪器接收新软件包。

如果跟踪器在每个软件包中发送您的ID,则此类型的服务器(套接字)可以正常工作,但是现在,新型Tracker(JIMI VL02)只需在第一个软件包(登录软件包)中发送ID,并且如果我关闭了他发送的Conection再次登录软件包。

那么,我该如何与跟踪器保持反应?我对插座的了解不多。如果有人知道插座类型的名称,我需要它会很有帮助

I need to do a Socket serv (gateway) to receive data packages from a car tracker (JIMI VL02).

The problem is: i dont know how to keep the conection with the tracker.

The oldest serv that i made (for other type of car tracker) was quit the connection after receive a package, like the example below.

localip = ''
port = 5005
bufferSize = 1024
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR,1)
server.bind((localip, port))
server.listen()

while True:
    client, adress = server.accept()  
    main(client, adress) 

def main():
  .
  .
  .
 client.close()   

In the function main i made the whole necessary process with the package and after that the code close the conection to receive a new package from other or the same tracker.

This type of server (socket) works if the tracker send your ID in every each package, but now the new type of tracker (JIMI VL02) just send the ID in the first package (login package) and if i close the conection he send again the login package.

So how can i keep the conection with the tracker? i don't know much about sockets. If anyone knows the name of the type of sockets i need it will help a lot already

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文