Giter VIP home page Giter VIP logo

winsockhttpserver's Introduction

Winsock pratice

目标

使用 winsock 实现 HTTP Server

描述

绑定端口接受 browser 请求,开启新的 sock 网络连接 ras(remote assess shell) 服务器。

这个对话框程序既是 Server 也是 Client。

对于 Web browser 来说是 Server,对 ras 来说是 Client。

winsock 需要完成下面几个任务:

  1. 解析 HTTP 请求(主要是 requestline,接受 GET method)
  2. WSAAsyncSelect 网络连接到多个 ras
  3. 对每个 ras open 对应 batfile (批处理输入文件),文件名由 GET method 中的参数指定。文件再工程根目录下,命名格式为:t1.txt ~ t5.txt
  4. ras 服务器接受输出数据,并与输入文件中的指令(batfile)一起打包成 html 格式。
  5. 加上 http 请求响应格式后,输出回 browser。

nonblocking 是通过 WASAsyncSelect 来完成。

测试

  • 在远程服务器上提前开启 ras 服务等待接受连接,如下:

  • 浏览器输入 127.0.0.1:port,窗口出现如下效果, prot define 在文件头部。

  • 完整测试为在浏览器输入:http://127.0.0.1:7799/hello.cgi?h1=nplinux4.cs.nctu.edu.tw&p1=12344&f1=t1.txt&h2=nplinux4.cs.nctu.edu.tw&p2=12344&f2=t3.txt

其中 h1=nplinux4.cs.nctu.edu.tw h2=nplinux4.cs.nctu.edu.twras 所在 IP 地址,p1 p2 分别为对应的端口号,f1 f2 则为批处理输入文件。

效果如下:

winsockhttpserver's People

Contributors

david-guo avatar

Watchers

James Cloos avatar  avatar

Forkers

isuker

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.