DEV Community

Cover image for Building a Web server in Bash, part I - sockets

Building a Web server in Bash, part I - sockets

Leandro Proença on August 01, 2022

Have you ever wondered how a Web server works under the hood? Moreover, would you be willing to sharpen your Shell scripting skills? Maybe this gu...
Collapse
 
artydev profile image
artydev

Awesome ;-)

Collapse
 
ricky11 profile image
Rishi U

Thanks for this. I am m using macos terminal, when invoking the nc -Uvl server.sock command there is no prompt thereafter. Do i need to update nc or bash?

Collapse
 
leandronsp profile image
Leandro Proença • Edited

Good question, unfortunately AFAIK the verbose in macOS for netcat is not as good as in Linux

Collapse
 
rizkyrajitha profile image
Rajitha Gunathilake

really informative article , thank you

Collapse
 
excessioneleven profile image
ExcessionEleven

Awesome content. This will help me to integrate much more power in my personal framework. Thank you

Collapse
 
namaku1801 profile image
Mohamad Fikri • Edited

In my experience using this tutorial, the script only makes single request. Of course this can be handled by using a single ampersand (&), or using GNU Parallel, but it's still ineffective, as you have to explicitly define the number of threads. I think this is another reason why no one writes web frameworks in bash

Collapse
 
leandronsp profile image
Leandro Proença

using socat we are able to perform requests using fork. we can’t use threads here, there’s no way to pthread_create from a standalone bash script.