问题标签 [python-sockets]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
python - Asyncio:非常简单的写入和断开 UDP 客户端的问题
我想尝试asyncio
Python 3.5.1 中的新模块。这是我的测试代码:
当我运行它时,解释器给了我:
我认为这是由 and 的顺序引起self.transport.sendto(self.message.encode())
的self.transport.close()
。如果我理解正确,该sendto
方法是异步的,它实际上是在我通过调用该方法关闭套接字后被调用的close
。有没有办法解决这个问题?
python - 使用python的HTTP URL嗅探器
我正在跟踪浏览网址,仅在所有操作系统(Windows、Linux、Mac)中传出数据包
我可以使用 python 套接字读取 TCP 数据包,但无法找到 URL 域名。
请指导或建议我实现这一目标。
python - Python - 除了cntrl-c之外,从键盘输入安全地关闭终端上的套接字连接?
我正在与之通信的服务器具有流会话槽,有时流会话无法打开,因为所有流会话槽都已使用。我怀疑它是因为我正在构建一个与服务器对话的程序,并且当我 cntrl-c 强制停止流时它不会安全关闭,从而保持流会话插槽为服务器上的实例连接打开。所以当我终止程序几十次时,这个错误就会累积起来
我对 Python Networking 知之甚少,不知道 cntrl-c 是否像敲击键并调用方法 close_conn(sock) 一样干净,但我想尝试一下。
假设我在我的终端上运行它”
出于调试目的,如何安全地关闭连接?
python - Python UDP socket resend data if no data recieved
I want to send some data to a sensor and if the python script doesn't receive the data I want the receive function to timeout and resend the data.
At the moment it gets stuck in the receive function if it doesn't receive any data:
However I want it to timeout after e.g. 2 seconds and rerun the subscribe() function.
I've tried using a while true statement with a timeout and try/exception however I get a port currently in use even when closing the port. Also feel this way is messy.
Any ideas would be appreciated.
python - 在 Python 3 中使用套接字传输文件
我有以下客户端-服务器套接字应用程序可以将文件上传到服务器。
服务器代码:
客户端代码:
但是在服务器端,控制台输出是不停的“写入文件......”,最后文件没有被存储,它是一个空的 test.txt 文件
python - TCP客户端服务器不接收来自对方的任何数据
我使用 python 套接字模块编写了以下 TCP 客户端和服务器。但是,在我运行它们之后,没有给出任何输出。似乎程序无法从 recv_all 方法 Server 中的 while 循环中出来:
客户 :
python - Python stateful socket programming
I have a client-server socket python script. I want to keep the state of each connection, such that I identify whether or not the client is its first connection. I unsuccessfully wrote the following code:
Each time the client connect I am getting an empty clients dictionary. Seems like each time there is a connection setup is being called and empties the dictionary clients
. How can I keep its state at each connection?
python - 用于多连接处理的 Python 套接字服务器
有人可以为套接字服务器提出一个很好的例子,它可以处理来自 python 的线程的多个连接。(将从线程处理的实时连接(如服务器-客户端乒乓球))
python - 同步socket编程python
我有一个由三轮组成的客户端-服务器应用程序。在每一轮,客户端向服务器发送一个文件,服务器计算某事并将其发送回客户端。客户端根据收到的消息为下一轮准备消息等。
该应用程序有时运行顺利,有时不顺利。我想问题是回合之间缺乏某种同步。例如,在客户端发送第二轮消息之前,服务器已经开始第二轮,这会产生问题。
除了套接字和 ThreadedTCPHandler,我不使用任何网络模块。我如何断言我的应用程序等待其他网络实体在开始执行之前发送其消息,而不会造成死锁