Main  /  Edit version 136  /  Edit version 137  /   /  Users Area

Difference "CppCMS — High Performance C++ Web Framework" ver. 136 versus ver. 137

Content:

What is [CppCMS](http://cppcms.com/)? CppCMS is a [Free](http://en.wikipedia.org/wiki/Free_and_open_source_software) High Performance Web Development Framework (_not a CMS_) aimed at [Rapid](http://en.wikipedia.org/wiki/Rapid_application_development) Web Application Development. It differs from most other web development frameworks like: Python Django, Java Servlets in the following ways:
1. It is designed and tuned to handle extremely high loads.
2. It uses modern C++ as the primary development language in order to achieve the first goal.
3. It is designed for developing both Web Sites and Web Services.
It is available under open source LGPLv3 license and
alternative [Commercial License](http://commercial.cppcms.com) for users who needs
an alternative license for proprietary software development.
See "[Rationale](/wikipp/en/page/rationale)" for further explanations.
### General
- [FAQ](/wikipp/en/page/faq)
- [Rationale Behind CppCMS](/wikipp/en/page/rationale)
- [Case Study: CppCMS Benchmarks](/wikipp/en/page/benchmarks)
- [Developers](/wikipp/en/page/developers)
- [When to Use](/wikipp/en/page/when_to_use_cppcms)
- [Who Uses CppCMS](/wikipp/en/page/who_uses)
- [Road Map to Future](/wikipp/en/page/cppcms_1x_tasks)
- [Secure Programming with CppCMS](/wikipp/en/page/secure_programming)
- [Downloads](http://sourceforge.net/projects/cppcms/files/)
- [Repositories](/wikipp/en/page/apt)
- [How to Contribute](/wikipp/en/page/contrib)
- [Project Logo](/wikipp/en/page/logo)
- [Project Logo](/wikipp/en/page/logo
### Framework Documentation
- [CppCMS 1.x.x - Stable](/wikipp/en/page/cppcms_1x)
- [CppCMS 0.0.x - Old Stable (deprecated)](/wikipp/en/page/cppcms_0x)
- [About the CppCMS versioning scheme](/wikipp/en/page/cppcms_versioning_scheme)
### SQL Connectivity
- [SQL Connectivity](/wikipp/en/page/sql_connectivity)
### CppCMS Based Applications
- [Wikipp - High Performance Wiki Engine](/wikipp/en/page/install_wikipp)
- [CppBlog - High Performance Blog Engine](/wikipp/en/page/install_cppblog)
<h1>include <iostream></h1> <h1>include <string></h1> <h1>include <cstring></h1>

include <sys/socket.h>

include <netinet/in.h>

include <unistd.h>

int main() { int server_fd, client_fd; struct sockaddr_in address; int addrlen = sizeof(address);

// HTML content to be served
std::string html = 
    "HTTP/1.1 200 OK\r\n"
    "Content-Type: text/html\r\n\r\n"
    "<!DOCTYPE html>"
    "<html>"
    "<head><title>My C++ Web</title></head>"
    "<body><h1>Welcome to a Simple Web Page!</h1><p>This is served from C++.</p></body>"
    "</html>";

// Create socket
server_fd = socket(AF_INET, SOCK_STREAM, 0);
if (server_fd == 0) {
    perror("socket failed");
    exit(EXIT_FAILURE);
}

// Bind
address.sin_family = AF_INET;
address.sin_addr.s_addr = INADDR_ANY;
address.sin_port = htons(8080);

if (bind(server_fd, (struct sockaddr *)&address, sizeof(address)) < 0) {
    perror("bind failed");
    exit(EXIT_FAILURE);
}

// Listen
if (listen(server_fd, 3) < 0) {
    perror("listen");
    exit(EXIT_FAILURE);
}

std::cout << "Server is running on http://localhost:8080" << std::endl;

while (true) {
    // Accept client
    client_fd = accept(server_fd, (struct sockaddr *)&address, (socklen_t*)&addrlen);
    if (client_fd < 0) {
        perror("accept");
        exit(EXIT_FAILURE);
    }

    char buffer[3000] = {0};
    read(client_fd, buffer, 3000);  // Read client request

    std::cout << "Request:\n" << buffer << std::endl;

    // Send response
    send(client_fd, html.c_str(), html.size(), 0);
    close(client_fd); // Close connection
}

return 0;

}

<h1>include <iostream></h1> <h1>include <string></h1> <h1>include <cstring></h1>

include <sys/socket.h>

include <netinet/in.h>

include <unistd.h>

int main() { int server_fd, client_fd; struct sockaddr_in address; int addrlen = sizeof(address);

// HTML content to be served
std::string html = 
    "HTTP/1.1 200 OK\r\n"
    "Content-Type: text/html\r\n\r\n"
    "<!DOCTYPE html>"
    "<html>"
    "<head><title>My C++ Web</title></head>"
    "<body><h1>Welcome to a Simple Web Page!</h1><p>This is served from C++.</p></body>"
    "</html>";

// Create socket
server_fd = socket(AF_INET, SOCK_STREAM, 0);
if (server_fd == 0) {
    perror("socket failed");
    exit(EXIT_FAILURE);
}

// Bind
address.sin_family = AF_INET;
address.sin_addr.s_addr = INADDR_ANY;
address.sin_port = htons(8080);

if (bind(server_fd, (struct sockaddr *)&address, sizeof(address)) < 0) {
    perror("bind failed");
    exit(EXIT_FAILURE);
}

// Listen
if (listen(server_fd, 3) < 0) {
    perror("listen");
    exit(EXIT_FAILURE);
}

std::cout << "Server is running on http://localhost:8080" << std::endl;

while (true) {
    // Accept client
    client_fd = accept(server_fd, (struct sockaddr *)&address, (socklen_t*)&addrlen);
    if (client_fd < 0) {
        perror("accept");
        exit(EXIT_FAILURE);
    }

    char buffer[3000] = {0};
    read(client_fd, buffer, 3000);  // Read client request

    std::cout << "Request:\n" << buffer << std::endl;

    // Send response
    send(client_fd, html.c_str(), html.size(), 0);
    close(client_fd); // Close connection
}

return 0;

}


Navigation

Main Page


Valid CSS | Valid XHTML 1.0