day5-simple ftp
博客专区 > Bing- 的博客 > 博客详情
day5-simple ftp
Bing- 发表于2年前
day5-simple ftp
  • 发表于 2年前
  • 阅读 8
  • 收藏 0
  • 点赞 2
  • 评论 0

标题:腾讯云 新注册用户域名抢购1元起>>>   

client:

#!/usr/bin/env python
#coding:utf-8
#author:Bing

import socket

client = socket.socket()
ip_port = ("127.0.0.1",9999)
client.connect(ip_port)

while True:
    data = client.recv(1024)
    print data
    
    inp = raw_input("data:")
    client.send(inp)
    if inp == "exit":
        break

simple progress:

#!/usr/bin/env python
#coding:utf-8
#author:Bing

import socket

server = socket.socket()
ip_port = ("127.0.0.1",9999)
server.bind(ip_port)
server.listen(5)

while True: 
    conn,address = server.accept()
    conn.send("hello..!")
    flag = True
    while flag:
        data = conn.recv(1024)
        print data
        if data == "1" :
            conn.send("this is test")
        elif data == "exit":
            flag = False
        else:
            conn.send("Guess")
    conn.close()

multipprogress:

#!/usr/bin/env python
#coding:utf-8
#author:Bing

import SocketServer

class Myserver(SocketServer.BaseRequestHandler):
    def setup(self):
        pass
    
    def handle(self):
        while True: 
            conn = self.request
            conn.send("hello..!")
            flag = True
            while flag:
                data = conn.recv(1024)
                print data
                if data == "1" :
                    conn.send("this is test")
                elif data == "exit":
                    flag = False
                else:
                    conn.send("Guess")
            conn.close()
    
    def finish(self):
        pass
    
    
if __name__ == "__main__":
    server = SocketServer.ThreadingTCPServer(("127.0.0.1",9999),Myserver)
    server.serve_forever()
    

simple ftp server:

 

共有 人打赏支持
粉丝 0
博文 25
码字总数 18863
×
Bing-
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额: