Skip to Content
Programación Reactiva con RxJava
book

Programación Reactiva con RxJava

by Tomasz Nurkiewicz, Ben Christensen
October 2024
Intermediate to advanced
372 pages
10h 35m
Spanish
O'Reilly Media, Inc.
Content preview from Programación Reactiva con RxJava

Apéndice A. Más ejemplos de servidores HTTP

Este apéndice amplía el contenido de "Vencer el problema C10k" proporcionando más ejemplos de servidores HTTP. Estos ejemplos no son imprescindibles para comprender el Capítulo 5, pero puede que te resulten interesantes. Además, algunos de estos ejemplos se incluyen en los puntos de referencia.

Procedimiento fork() en lenguaje C

Intentaremos implementar un servidor HTTP concurrente utilizando C. Si estás familiarizado con C, el siguiente programa te resultará bastante sencillo. De lo contrario, no te preocupes, no estás obligado a entender todos los detalles, sólo la idea general. Al invocar fork() se hace una copia del proceso actual, de modo que de repente aparecen dos procesos en el sistema operativo: el original (padre) y un hijo. Este segundo proceso tiene exactamente las mismas variables y el mismo estado, la única diferencia es el valor del resultado de fork():

#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include <netinet/in.h>
#include <unistd.h>
#include <stdio.h>

int main(int argc, char *argv[]) {
  signal(SIGCHLD, SIG_IGN);
  struct sockaddr_in serv_addr;
  bzero((char *) &serv_addr, sizeof(serv_addr));
  serv_addr.sin_family = AF_INET;
  serv_addr.sin_addr.s_addr = INADDR_ANY;
  serv_addr.sin_port = htons(8080);
  int server_socket = socket(AF_INET, SOCK_STREAM, 0);
  if(server_socket < 0) {
    perror("socket");
    exit(1);
  }
  if(bind(server_socket,
        (struct sockaddr *) &serv_addr,
        sizeof(serv_addr)) < 0) {
    perror("bind");
    exit ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Dominar la arquitectura API

Dominar la arquitectura API

James Gough, Daniel Bryant, Matthew Auburn
De Java a Kotlin

De Java a Kotlin

Duncan McGregor, Nat Pryce

Publisher Resources

ISBN: 9798341603585