小编jug*_*108的帖子

使用 ncat 在套接字上运行 python 脚本?

我想让一个 python 脚本在 LAN 中的服务器套接字上运行。我写了一个数字猜测脚本,我想让它在套接字上运行,以便其他客户端通过连接到端口(比如 1234)来使用它。我知道可以通过 python 的套接字编程来实现这一点。但这个问题是问为什么这会失败?

ncat 192.168.0.108 -lvp 1234 -e /usr/bin/python3.5 number_game.py

剧本:

#!/usr/bin/python3.5
import random
num=random.randint(1,20)
flag=0
print("Welcome to the game...")
for i in range(1,7):
    print("Take a guess")
    guess=int(input())
    if guess > num:
        print("Way too high")
    else:
        if guess < num:
            print("Way too low")
        else:
            flag=1
            break;
if flag == 1:
    print("You made it in "+str(i)+" attempts")
else:
    print("better luck next time")
Run Code Online (Sandbox Code Playgroud)

错误:

Ncat: Version 7.31 ( https://nmap.org/ncat ) Ncat: Got more than one port specification: …

command-line networking python

1
推荐指数
1
解决办法
5311
查看次数

标签 统计

command-line ×1

networking ×1

python ×1