zoukankan      html  css  js  c++  java
  • @server,clients简单实例

    服务端:
    import socket
    import time
    socket = socket.socket()
    ip = socket.bind(('192.168.15.85',8000))
    socket.listen(5)
    conn,add = socket.accept()#阻塞等待

    # while True:
    # s = conn.recv(1024) # 接受bytes类型
    # t = s.decode('utf-8') #转换成字符串
    # dd = time.localtime(float(t))
    # td = time.strftime("%Y/%m/%d %H:%M:%S",dd)
    # print(td)

    # # input('请输入聊天文字:')
    # s='发送'
    # # conn.send(s.encode('utf-8'))
    # socket.close()


    #
    # while True:
    # s = conn.recv(1024)
    # t = s.decode('utf-8')
    # print('收到:%s' % t)
    # ss = input('输入框:')
    # ts =conn.send(ss.encode('utf-8'))


    客户端:
    import socket
    import time
    socket = socket.socket()
    ip = ('192.168.15.85',8000)

    socket.connect(ip)

    # while True:
    # time.sleep(2)
    # s= time.time()
    # socket.send(str(s).encode('utf-8'))
    # #
    # # t = socket.recv(1024)#阻塞住 等待接受
    # # ts = t.decode('utf-8')
    # # print(ts)
    # socket.close()



    # while True:
    # s = input('输入框:')
    # socket.send(s.encode('utf-8'))
    # o = socket.recv(1024)
    # oo = o.decode('utf-8')
    # print('收到:%s'% oo)



  • 相关阅读:
    Maven Resources Plugin
    Git Delete Last Commit
    查看剩余空间
    使用 Jython 连接 Apache Derby 数据库
    JVM动态语言比武
    jython embedded into java
    maven testNG
    why clojure?
    jython一小时学会
    gnote
  • 原文地址:https://www.cnblogs.com/li-123-peng/p/9794951.html
Copyright © 2011-2022 走看看