Making Minimalist Web Server in C on Windows

Поділитися
Вставка
  • Опубліковано 24 бер 2024
  • In this video I will demonstrate how to make a simple web server in C on Windows using Windows Sockets (winsock).
    Code: gist.github.com/nir9/2db83a89...
  • Наука та технологія

КОМЕНТАРІ • 59

  • @nirlichtman
    @nirlichtman  2 місяці тому +7

    - Notice that the program finishes after the first connection to the server, so make sure to bring it up again after each connection
    - If you have a problem loading the web page on your browser try adding closesocket, wsacleanup and increasing the size of the request buffer, as possible remedies
    - Notice that when working with the MS docs, make sure you are opening the winsock2.h page for each function, and not winsock.h (for example for bind, use "bind function (winsock2.h) - Win32 apps" and not "bind function (winsock.h) - Win32 apps"

  • @ItsCOMMANDer_
    @ItsCOMMANDer_ 2 місяці тому +19

    Good old winsock2

  • @djanthony6662
    @djanthony6662 Місяць тому

    This brings back so many memories, good days. Great & to the point presentation.

  • @cherifaly6757
    @cherifaly6757 2 місяці тому +3

    Thank you sir, please make tutorial for ssl webserver for windows. 🙂

  • @KimTiger777
    @KimTiger777 2 місяці тому +3

    Excellent teaching strait to the point. If only SSL was as easy to implement in Windows as it was for Linux, maybe I am wrong but when I tried I just hit one road block after another. Anyway it was cool to see Winsock in action. 👍

  • @space9824
    @space9824 2 місяці тому +1

    You, sir, are a legend! How can I support your content?

    • @nirlichtman
      @nirlichtman  2 місяці тому +1

      Thanks for the compliment! I will consider enabling super thanks in the future, after I setup my adsense properly :)

  • @BillyRichardson
    @BillyRichardson 2 місяці тому +2

    very cool

  • @KimTiger777
    @KimTiger777 2 місяці тому

    Today I learned how to make custom add new files in Visual Studio 2022 which is useful for adding new C++ classes (header+source) in one go, also added C source just for good measure. So maybe that could be an idea for a new video, it is not much to do once one figure the _how_ part through Microsoft's online documentation. I believe this feature isn't widely known even by experienced C/C++ programmers using Visual Studio, learning this will lead to a tiny bit better Quality-of-Life for those who use it on a daily basis.

  • @angelffg
    @angelffg 2 місяці тому

    Nice video Nir ;-)

  • @justinnamilee
    @justinnamilee 2 місяці тому

    NIce.

  • @aviinl1
    @aviinl1 2 місяці тому

    winsock2, flashbacks to the vb6 days lol

  • @Kknewkles
    @Kknewkles 2 місяці тому

    Was the stocks counter made in one of the previous videos?...

    • @nirlichtman
      @nirlichtman  2 місяці тому

      Which stock counter?

    • @Kknewkles
      @Kknewkles 2 місяці тому

      @@nirlichtman ah, it's the weather/news widget :'D

    • @nirlichtman
      @nirlichtman  2 місяці тому +2

      Yah it's the built in Windows widget, but that is a good idea for a future video

  • @Simpfey
    @Simpfey 2 місяці тому

    Hey I have a problem where when I compile there is no compiler errors, but when I run it just says that program a.exe stopped working, I have changed the code a little to handle errors using if statements and also making 404 error when inputting a file that doesnt exist

    • @nirlichtman
      @nirlichtman  2 місяці тому

      You mean the program just crashes when you run it? Have you tried running with a debugger like windbg? It will help you diagnose the reason for the crash.

    • @Simpfey
      @Simpfey 2 місяці тому

      @@nirlichtman Okay so I fixed the error, I suppose the buffer size was too big because I set it own customly so then I changed the size of it to 1024B and It worked, but can you tell me how to make it possible to access multiple files except only index.html?

  • @zawadhyaa
    @zawadhyaa 2 місяці тому

    a linux from scratch video next please!!!

  • @user-nh6qi2zu1b
    @user-nh6qi2zu1b 20 днів тому

    making Minimalist Web Server in Windows but using systemcall instruction?

  • @guilherme5094
    @guilherme5094 2 місяці тому +1

    👍

  • @rocknowradio
    @rocknowradio 2 місяці тому

    Well, "GET /\0" will never be served. And this is what the default GET will be.

    • @nirlichtman
      @nirlichtman  2 місяці тому

      In most cases, browsers and HTTP command line tools add additional metadata after "GET /", so it shouldn't be a problem

  • @meninoesperto2773
    @meninoesperto2773 2 місяці тому +1

    Show a web server using epoll

  • @footballuniverse6522
    @footballuniverse6522 2 місяці тому +2

    ...how?

  • @anon_y_mousse
    @anon_y_mousse 2 місяці тому

    This has me wondering if you can install `man` on Windows. If so, maybe you should give that a try since it would be easier to look up all of the C standard library functions.

    • @nirlichtman
      @nirlichtman  2 місяці тому +1

      It would indeed be cool to somehow look up Windows API functions with a man style command, I wonder if one exists - when I have more time I will look into this, perhaps if doesn't exist, could be interesting to write a script that converts the microsoft docs to man pages, the raw MS doc files are all on Github.

    • @anon_y_mousse
      @anon_y_mousse 2 місяці тому

      @@nirlichtman I didn't know they had them up on GH. That'll make it a lot easier since you wouldn't need to web scrape. Although, both would make cool videos, converting their raw files into man pages and web scraping.

    • @nirlichtman
      @nirlichtman  2 місяці тому +1

      @@anon_y_mousse Yah the way it works is that the have some kind of format for their docs on github and then they build these files into the docs which are available online. it could def be an interesting video to somehow parse and convert their docs format to man pages, i'll add to my list

  • @FizzlNet
    @FizzlNet Місяць тому +1

    Good old WINAPI. "Oh? Unix had a widely used standard way to do these things. Better make ours double-not-compatible so porting any stuff between our systems is impossible!"

  • @plato4ek
    @plato4ek 2 місяці тому

    9:31 this should be "text/plain", not "text/html"

    • @Lastninjaxoxoxoxox
      @Lastninjaxoxoxoxox 19 днів тому

      no it should be text/html

    • @plato4ek
      @plato4ek 17 днів тому

      @@LastninjaxoxoxoxoxWhy do you think that? It's clearly a plain text, not html.

  • @Kyoz
    @Kyoz 2 місяці тому

    🤍