🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.os.linux.programacion
Article #14299

Re: Sockets y multiples conexiones.

#14299
From: root
Date: Mon, 20 Nov 2000 00:00
29 lines
1465 bytes
Mirate esto.... con fork() lo que hago es llamar un proceso hijo para
cada conexion :)

---//---
    #include <netinet/in.h>
    #include <stdio.h>
    #include <unistd.h>

    void main()
    {
        int child;
        int fdc, fdl = socket(AF_INET, SOCK_STREAM, 6);
        struct sockaddr_in dir = {AF_INET, htons(900), INADDR_ANY };
        char ch;

        bind(fdl, (struct sockaddr_in*) &dir, sizeof(dir));
        listen(fdl, 128);

        child=fork();
        if (child==0) {
            fdc = accept(fdl, NULL, NULL);
            close(fdl);
            while (read(fdc, &ch, 1)) write(1, &ch, 1);
            printf("\n");
        }
    }
---//---

Un saludo... suerte.
Technical Details
Message-ID: <3A197AB4.86365CE@wanadoo.es>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <9ks9u8.jc.ln@127.0.0.1> <o64eu8.nb1.ln@127.0.0.1>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f86c8,8bfdad65296f88d
X-Google-Attributes: gidf86c8,public
From: root <"fempiña"@wanadoo.es>
Subject: Re: Sockets y multiples conexiones.
Date: 2000/11/20
Message-ID: <3A197AB4.86365CE@wanadoo.es>
X-Deja-AN: 695867750
Content-Transfer-Encoding: 7bit
References: <9ks9u8.jc.ln@127.0.0.1> <o64eu8.nb1.ln@127.0.0.1>
X-Accept-Language: en
Content-Type: text/plain; charset=us-ascii
X-Complaints-To: abuse@wanadoo.es
X-Trace: m2newsread.uni2.es 974748476 62.36.131.86 (Mon, 20 Nov 2000 20:27:56 MET)
Organization: Servidor Usenet News de Uni2/Wanadoo
MIME-Version: 1.0
NNTP-Posting-Date: Mon, 20 Nov 2000 20:27:56 MET
Newsgroups: es.comp.os.linux.programacion