Giter VIP home page Giter VIP logo

simple-smtp-receive-2's Introduction

Simple-SMTP-receive-2

在Simple-SMTP-receive-client的基础上加入多线程

结构大致如下: 程序启动时,在主线程中打开一个主窗口。有两个按钮,开始监听和关闭。 点击开始按钮,会创建一个监听线程,来监听本机的25端口,等待接收连接。

收到新连接后,创建一个新的套接字来与请求的客户端建立TCP连接。然后将这个socket的句柄detach出来。通过消息机制发送给主线程。 主线程在当前线程创建一个显示接收邮件的新窗口,和一个新的接收邮件子线程。将socket句柄传递给子线程。使子线程在来处理与客户端SMTP的交互。

接收邮件子线程在SMTP协议的 命令交互阶段会同步的把交互的命令传递到对应的显示邮件的窗口。 数据传输阶段,在接收完整数据后,会根据MIME协议解析出其中的正文内容和附件。附件保存在本地。然后将正文内容和附件名列表传递给显示邮件的窗口。 子线程处理完成后,会清理自己各个变量占用的内存空间,然后退出。

显示邮件的窗口在用户点击关闭会调用OnClose(),先清理自身变量占用的内存空间,然后检查对应的邮件接收子线程是否已经关闭,若没有则发送关闭的消息,最后直接调用DestroyWindow()关闭自身。

使用子线程的好处是在接受来自客户端的大文件时,也可以保证窗口是可以被操作的,不会陷入无响应的情况。

simple-smtp-receive-2's People

Contributors

huangxxuuu 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.