Angus Leeming <[EMAIL PROTECTED]> writes:

| On Wednesday 11 September 2002 11:21 pm, Lars Gullik Bjønnes 
>
>> No, they don't share the same socket.
>>
>> it will be code "like" this:
>>
>> int sock = socket(ARGS)
>> bind(sock, ARGS)
>> while true; do
>>     int new_sock = accept(sock. ARGS);
>>     // register this new_sock with a stream
>>     // register it with a function object
>>     // deliver it to the event loop
>> done
>
| Lars, I have your LocalSocket.[Ch] files. Could you send me a 
| piece of code that uses them. I'm one of those who learn best 
| from examples.

I do not have complete examplers that I can show you.

bu tin one piece of code I have a LocalClientListener that works
together with the LocalSocket (here called LocalConnection... it does
some ssl stuff and challenge-response in addition to just being a
socketstream)


the main loop in the LocalClientListener looks like this:

        sock_.listen(5);

        int reuse_addr = 1;
        setsockopt(sock_.getSocket(), SOL_SOCKET, SO_REUSEADDR, &reuse_addr,
                   sizeof(reuse_addr));

        while (true) {
                boost::shared_ptr<LocalSocket> msgsock(sock_.accept());
                if (msgsock->isOK()) {

                        // Get the secret:
                        string const secret = gs("dummy");

                        // Setup SSL + check sertificates + etc

                        LocalConnection connection(msgsock, chr_,
                        secret);
                        // This passes the connection to the handler
                        // for new connections.
                        newConnection(connection);
                } else {
                        std::cerr << "Error yet again!" << std::endl;
                }
        }

-- 
        Lgb

Reply via email to