RejectedSoftware Forums

Sign up

Internal Workings of listenHTTP

How does listenHTTP work internally? I understand it listens on the address you provide it in the HTTPServerSettings object, but what happens after?

I have been browsing a bit through the source code to end up in a dead end. I ended up at the listenHTTPPlain function, which to my understanding sets up the socket and starts listening on it using listenTCP. This function seems to do nothing but call itself though. How does that work?

Re: Internal Workings of listenHTTP

On Sat, 01 Feb 2014 23:07:47 GMT, Jeroen Bollen wrote:

How does listenHTTP work internally? I understand it listens on the address you provide it in the HTTPServerSettings object, but what happens after?

I have been browsing a bit through the source code to end up in a dead end. I ended up at the listenHTTPPlain function, which to my understanding sets up the socket and starts listening on it using listenTCP. This function seems to do nothing but call itself though. How does that work?

listenHTTPPlain sets up a callback to handleHTTPConnection from there the control-flow goes to handleRequest and there the real fun starts

Re: Internal Workings of listenHTTP

Am 02.02.2014 09:40, schrieb Stefan Koch:

On Sat, 01 Feb 2014 23:07:47 GMT, Jeroen Bollen wrote:

How does listenHTTP work internally? I understand it listens on the address you provide it in the HTTPServerSettings object, but what happens after?

I have been browsing a bit through the source code to end up in a dead end. I ended up at the listenHTTPPlain function, which to my understanding sets up the socket and starts listening on it using listenTCP. This function seems to do nothing but call itself though. How does that work?

listenHTTPPlain sets up a callback to handleHTTPConnection from there the control-flow goes to handleRequest and there the real fun starts

Exactly, the interesting part is in listenTCP, which will call the
supplied callback whenever an incoming connection is established.

Re: Internal Workings of listenHTTP

All right, thanks for the help.