Coder Social home page Coder Social logo

socket-python's Introduction

Socket-Python

主要实现客户端即工控机和云服务器端进行的文件传输,使用的主要方法是通过Socket传输,其底层就是TCP连接传输,主要目的是工控机将录制的视频传输到云端储存,其应用背景可为目标检测等;其中云服务器端必须一直运行接收文件的程序,而客户端只需要连接云服务器端的公网进入特定端口号即可实现连接。

Development Environment

  • Python3
  • socket
  • time
  • struct
  • cv2
  • os

Content

|-- README.md
|-- camera_client.py    # 使用摄像头进行视频录制并传输文件的客户端代码
|-- file_client.py      # 传输任何文件的客户端代码
|-- file_server.py      # 接收任何文件的服务端代码
|-- text_client.py      # 传输文本信息的客户端代码
|-- text_server.py      # 接收文本信息的服务端代码
|-- server.py           # 集成MQTT和Socket的服务端代码

# 其中传输和接收文本信息的代码有点冗余了但是还是都放上去,真正主要的代码并可移植
# 的就是file_client和file_server,camera_client主要是测试在目标检测的时候客户
# 端模拟检测到目标并录制一小段视频然后录制完毕就马上传输到云服务器

How to use

  • 开通云服务器,并且打开特定端口,端口可以自己指定没有特别要求,但是有些端口号默认是被占用的

  • 在客户端代码中设置好要连接的公网IP和指定的端口号,然后运行python file_client.py
    images1

  • 在云服务器上同样设置好端口号及云服务器的本地IP,然后运行python file_server.py

Results

  • 下面展示了云服务器端接收和客户端模拟发送视频文件的结果图

images3

images4

socket-python's People

Contributors

yurizzzzz avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.