我是使用 python 进行网络连接的新手。我正在使用 socket.sendto()
函数。我想知道是否可以通过该函数发送更多参数以及消息字符串,就像在时间戳中一样。我刚刚向 sendto 函数添加了一个变量。但这会抛出TypeError: Integer required
。为什么会这样呢?我如何发送附加参数?
最佳答案
I want to know if more arguments can be sent through the function
socket.sendto(string, address)
socket.sendto(string, flags, address)
Send data to the socket. The socket should not be connected to a remote socket, since the destination socket is specified by
address
. The optionalflags
argument has the same meaning as forrecv()
above. Return the number of bytes sent. (The format of address depends on the address family — see above.)
socket
不是一个高级接口(interface);您发送字节并接收字节。您要发送的所有数据都应在 string
参数中进行编码,并在接收端进行解码。
关于python - 通过 socket.sendto() 发送附加参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18669064/