C++ Web Development: Wanting a minimalist start [closed]

I’m currently working on a Computer Science degree, and I want to build my own Web Server library. The problem? Every search I’ve done on interacting with web sites points to “Use this library that was built by someone else” – instead of explaining the basics of sending and receiving information.

I’m not asking for a lot – I just want to enter a single alpha-numeric character on a web page, hit a button, and have that one byte of information sent to a C++ program, without the aid of a non-standard library.

4

Boost.Asio is currently being converted to be (one of?) the future C++ standard way to do networking. (Here is one of the papers: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3388.pdf )

It’s really the most basic portable asynchronous communication system you will find using modern C++, as it abstract away other socket libraries or platform provided ones.

All the modern C++ http networking libraries (CppNetlib and CPPCMS) relies on it. I suggest you build your library around it provide basics for sockets and asynchronous (and synchronous) comunication but don’t setup a full system for you. Maybe in a few years you can even replace Boost.ASIO by the C++ standard equivalent.

Also, the documentation of Boost.Asio provide insight on how communication works in this kind of context. So reading it might answer a lot of your questions.

And if you want to understand the lower level, read the Asio code. It’s a bit hard to read if you’re not used to C++ meta-programming and other C++ idioms but you would learn a lot by reading it.

Some of tye info that you want is here – http://en.wikipedia.org/wiki/Common_Gateway_Interface . It might not sound like what you are trying to do is very complicated, but it’s a bit more complicated than you might think. As Dominic said the tricky part will be opening the port and reading from the socket – quite difficult in c++ land.

I would recommend that to start with, use an existing web server and write your own CGI module. The web server will take care of the sockets side of things, and basically you’re just reading data from environment variables or command line arguments (if it’s a GET request) or from the stdin if it’s a POST (I think, this is data from my memory that’s about 15 years old). What you want is something like this:

#include <stdio.h>
#include <string.h>

int main(){
    char *s=getenv("CONTENT_LENGTH");
    int i=atoi(getenv("CONTENT_LENGTH"));
    printf("Content-type: text/htmlnn");
    printf("%sn<br />",s); //Shows you CONTENT_LENGTH works
    printf("%dn<br />",i); //Shows you it was converted to int
    char *tmp = new char[100];
    fread(tmp,i,1,stdin); //read from stdin something of i bytes to tmp
    printf("%sn<br />",tmp);
    return 0;
}

BTW as a lesson for the reader this application has a buffer overflow bug.. you probably want to fix that 🙂

Correct me if I’m wrong, but it sounds like you want to program your own web server from scratch, using only standard C++ components.

First of all you are in a bit of a bind as there is no standard tcp/ip socket library, so you’ll need to use Windows sockets, or Posix sockets depending on platform.

Then you’ll need to research the format of requests/responses. I’m sure with a bit of searching you’ll find a resource on the http protocol.

After that you’ll need to create a server that listens for connections, responds to requests and sends responses.

If that isn’t what you are asking, then MichaelT’s suggestion sounds reasonable.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa

C++ Web Development: Wanting a minimalist start [closed]

I’m currently working on a Computer Science degree, and I want to build my own Web Server library. The problem? Every search I’ve done on interacting with web sites points to “Use this library that was built by someone else” – instead of explaining the basics of sending and receiving information.

I’m not asking for a lot – I just want to enter a single alpha-numeric character on a web page, hit a button, and have that one byte of information sent to a C++ program, without the aid of a non-standard library.

4

Boost.Asio is currently being converted to be (one of?) the future C++ standard way to do networking. (Here is one of the papers: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3388.pdf )

It’s really the most basic portable asynchronous communication system you will find using modern C++, as it abstract away other socket libraries or platform provided ones.

All the modern C++ http networking libraries (CppNetlib and CPPCMS) relies on it. I suggest you build your library around it provide basics for sockets and asynchronous (and synchronous) comunication but don’t setup a full system for you. Maybe in a few years you can even replace Boost.ASIO by the C++ standard equivalent.

Also, the documentation of Boost.Asio provide insight on how communication works in this kind of context. So reading it might answer a lot of your questions.

And if you want to understand the lower level, read the Asio code. It’s a bit hard to read if you’re not used to C++ meta-programming and other C++ idioms but you would learn a lot by reading it.

Some of tye info that you want is here – http://en.wikipedia.org/wiki/Common_Gateway_Interface . It might not sound like what you are trying to do is very complicated, but it’s a bit more complicated than you might think. As Dominic said the tricky part will be opening the port and reading from the socket – quite difficult in c++ land.

I would recommend that to start with, use an existing web server and write your own CGI module. The web server will take care of the sockets side of things, and basically you’re just reading data from environment variables or command line arguments (if it’s a GET request) or from the stdin if it’s a POST (I think, this is data from my memory that’s about 15 years old). What you want is something like this:

#include <stdio.h>
#include <string.h>

int main(){
    char *s=getenv("CONTENT_LENGTH");
    int i=atoi(getenv("CONTENT_LENGTH"));
    printf("Content-type: text/htmlnn");
    printf("%sn<br />",s); //Shows you CONTENT_LENGTH works
    printf("%dn<br />",i); //Shows you it was converted to int
    char *tmp = new char[100];
    fread(tmp,i,1,stdin); //read from stdin something of i bytes to tmp
    printf("%sn<br />",tmp);
    return 0;
}

BTW as a lesson for the reader this application has a buffer overflow bug.. you probably want to fix that 🙂

Correct me if I’m wrong, but it sounds like you want to program your own web server from scratch, using only standard C++ components.

First of all you are in a bit of a bind as there is no standard tcp/ip socket library, so you’ll need to use Windows sockets, or Posix sockets depending on platform.

Then you’ll need to research the format of requests/responses. I’m sure with a bit of searching you’ll find a resource on the http protocol.

After that you’ll need to create a server that listens for connections, responds to requests and sends responses.

If that isn’t what you are asking, then MichaelT’s suggestion sounds reasonable.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa

C++ Web Development: Wanting a minimalist start [closed]

I’m currently working on a Computer Science degree, and I want to build my own Web Server library. The problem? Every search I’ve done on interacting with web sites points to “Use this library that was built by someone else” – instead of explaining the basics of sending and receiving information.

I’m not asking for a lot – I just want to enter a single alpha-numeric character on a web page, hit a button, and have that one byte of information sent to a C++ program, without the aid of a non-standard library.

4

Boost.Asio is currently being converted to be (one of?) the future C++ standard way to do networking. (Here is one of the papers: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3388.pdf )

It’s really the most basic portable asynchronous communication system you will find using modern C++, as it abstract away other socket libraries or platform provided ones.

All the modern C++ http networking libraries (CppNetlib and CPPCMS) relies on it. I suggest you build your library around it provide basics for sockets and asynchronous (and synchronous) comunication but don’t setup a full system for you. Maybe in a few years you can even replace Boost.ASIO by the C++ standard equivalent.

Also, the documentation of Boost.Asio provide insight on how communication works in this kind of context. So reading it might answer a lot of your questions.

And if you want to understand the lower level, read the Asio code. It’s a bit hard to read if you’re not used to C++ meta-programming and other C++ idioms but you would learn a lot by reading it.

Some of tye info that you want is here – http://en.wikipedia.org/wiki/Common_Gateway_Interface . It might not sound like what you are trying to do is very complicated, but it’s a bit more complicated than you might think. As Dominic said the tricky part will be opening the port and reading from the socket – quite difficult in c++ land.

I would recommend that to start with, use an existing web server and write your own CGI module. The web server will take care of the sockets side of things, and basically you’re just reading data from environment variables or command line arguments (if it’s a GET request) or from the stdin if it’s a POST (I think, this is data from my memory that’s about 15 years old). What you want is something like this:

#include <stdio.h>
#include <string.h>

int main(){
    char *s=getenv("CONTENT_LENGTH");
    int i=atoi(getenv("CONTENT_LENGTH"));
    printf("Content-type: text/htmlnn");
    printf("%sn<br />",s); //Shows you CONTENT_LENGTH works
    printf("%dn<br />",i); //Shows you it was converted to int
    char *tmp = new char[100];
    fread(tmp,i,1,stdin); //read from stdin something of i bytes to tmp
    printf("%sn<br />",tmp);
    return 0;
}

BTW as a lesson for the reader this application has a buffer overflow bug.. you probably want to fix that 🙂

Correct me if I’m wrong, but it sounds like you want to program your own web server from scratch, using only standard C++ components.

First of all you are in a bit of a bind as there is no standard tcp/ip socket library, so you’ll need to use Windows sockets, or Posix sockets depending on platform.

Then you’ll need to research the format of requests/responses. I’m sure with a bit of searching you’ll find a resource on the http protocol.

After that you’ll need to create a server that listens for connections, responds to requests and sends responses.

If that isn’t what you are asking, then MichaelT’s suggestion sounds reasonable.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật