12.06.2015 Views

The Annoyance Filter.pdf - Fourmilab

The Annoyance Filter.pdf - Fourmilab

The Annoyance Filter.pdf - Fourmilab

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

§214 ANNOYANCE-FILTER POP3 PROXY SERVER CLASS DEFINITION 177<br />

214. We’re all done. Having relayed the reply to the “quit” command, or having something go blooie<br />

in the processing loop, we close the client and server sockets and get ready to bail out from servicing<br />

this connection.<br />

〈 Close the connection to the client and server 214 〉 ≡<br />

close (clientSocket );<br />

close (serverSocket );<br />

if (verbose ) {<br />

cerr ≪ "Closing␣POP3␣connection␣from␣" ≪ inet ntoa (from .sin addr ) ≪ endl ;<br />

}<br />

This code is used in section 200.<br />

215. If you simply wish to run a POP3 proxy server until the end of time, you can invoke this method<br />

which puts it all together. We return only if something blows up, after which the caller is well-advised<br />

to destroy the POP3Proxy object and try again.<br />

〈 Class implementations 11 〉 +≡<br />

#ifdef POP3_PROXY_SERVER<br />

bool POP3Proxy ::operateProxyServer (int maxBacklog )<br />

{<br />

if (acceptConnections (maxBacklog )) {<br />

while (serviceConnection ( )) ;<br />

}<br />

return false ;<br />

}<br />

#endif<br />

216. Various alarums and diversions will result in our receiving a SIGPIPE signal whilst acting as a<br />

POP3 server. <strong>The</strong>se may be safely ignored, as the following function does.<br />

〈 Declare signal handler function for broken pipes 216 〉 ≡<br />

static RETSIGTYPEabsentPlumber (int)<br />

{<br />

if (popProxyTrace ) {<br />

cerr ≪ "POP3:␣Caught␣SIGPIPE−−continuing." ≪ endl ;<br />

}<br />

signal (SIGPIPE, absentPlumber ); /∗ Reset signal just in case ∗/<br />

}<br />

This code is used in section 194.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!