File: Poco.Net.SocketAcceptor.html

package info (click to toggle)
poco-doc 1.3.6-1
  • links: PTS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, squeeze, stretch, wheezy
  • size: 10,076 kB
  • ctags: 9,611
  • sloc: makefile: 31
file content (99 lines) | stat: -rw-r--r-- 10,786 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Class Poco::Net::SocketAcceptor</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<meta name="author" content="Applied Informatics Software Engineering GmbH and Contributors"/>
<meta name="publisher" content="Applied Informatics Software Engineering GmbH and Contributors"/>
<meta name="copyright" content="Copyright (c) 2009, Applied Informatics Software Engineering GmbH and Contributors"/>
<meta name="language" content="en"/>
<meta name="date" content="2009-11-24"/>
<meta name="generator" content="PocoDoc"/>
<link rel="stylesheet" href="css/styles.css" type="text/css"/>
</head>
<body bgcolor="#ffffff" leftmargin="0" topmargin="0">
<div class="header">
<h1 class="namespace"><a href="Poco.Net.html" class="namespace">Poco::Net</a></h1>
<h1 class="template">template &lt; class ServiceHandler &gt;</h1>
<h1 class="symbol">class SocketAcceptor</h1>
</div>
<div class="body">
<p>
<b>Library:</b> Net<br />
<b>Package:</b> Reactor<br />
<b>Header:</b> Poco/Net/SocketAcceptor.h</p>
<h2>Description</h2>
<div class="description">
<p>This class implements the Acceptor part of the Acceptor-Connector design pattern. </p>
<p>The Acceptor-Connector pattern has been described in the book &quot;Pattern Languages of Program Design 3&quot;, edited by Robert Martin, Frank Buschmann and Dirk Riehle (Addison Wesley, 1997). </p>
<p>The Acceptor-Connector design pattern decouples connection establishment and service initialization in a distributed system from the processing performed once a service is initialized. This decoupling is achieved with three components: Acceptors,  Connectors and Service Handlers. The <a href="Poco.Net.SocketAcceptor.html" title="class Poco::Net::SocketAcceptor">SocketAcceptor</a> passively waits for connection requests (usually from a remote Connector) and establishes a connection upon arrival of a connection requests. Also, a Service Handler is initialized to process the data arriving via the connection in an application-specific way. </p>
<p>The <a href="Poco.Net.SocketAcceptor.html" title="class Poco::Net::SocketAcceptor">SocketAcceptor</a> sets up a <a href="Poco.Net.ServerSocket.html" title="class Poco::Net::ServerSocket">ServerSocket</a> and registers itself for a <a href="Poco.Net.ReadableNotification.html" title="class Poco::Net::ReadableNotification">ReadableNotification</a>, denoting an incoming connection request. </p>
<p>When the <a href="Poco.Net.ServerSocket.html" title="class Poco::Net::ServerSocket">ServerSocket</a> becomes readable the <a href="Poco.Net.SocketAcceptor.html" title="class Poco::Net::SocketAcceptor">SocketAcceptor</a> accepts the connection request and creates a ServiceHandler to service the connection. </p>
<p>The ServiceHandler class must provide a constructor that takes a <a href="Poco.Net.StreamSocket.html" title="class Poco::Net::StreamSocket">StreamSocket</a> and a <a href="Poco.Net.SocketReactor.html" title="class Poco::Net::SocketReactor">SocketReactor</a> as arguments, e.g.: </p>
<pre>MyServiceHandler(const StreamSocket&amp; socket, ServiceReactor&amp; reactor)
</pre>
<p>When the ServiceHandler is done, it must destroy itself. </p>
<p>Subclasses can override the <a href="Poco.Net.SocketAcceptor.html#15098" title="Poco::Net::SocketAcceptor::createServiceHandler()">createServiceHandler</a>() factory method if special steps are necessary to create a ServiceHandler object. </p>
</div>
<h2>Member Summary</h2>
<p><b>Member Functions: </b><a href="Poco.Net.SocketAcceptor.html#15098" title="Poco::Net::SocketAcceptor::createServiceHandler()">createServiceHandler</a>, <a href="Poco.Net.SocketAcceptor.html#15096" title="Poco::Net::SocketAcceptor::onAccept()">onAccept</a>, <a href="Poco.Net.SocketAcceptor.html#15100" title="Poco::Net::SocketAcceptor::reactor()">reactor</a>, <a href="Poco.Net.SocketAcceptor.html#15093" title="Poco::Net::SocketAcceptor::registerAcceptor()">registerAcceptor</a>, <a href="Poco.Net.SocketAcceptor.html#15101" title="Poco::Net::SocketAcceptor::socket()">socket</a>, <a href="Poco.Net.SocketAcceptor.html#15095" title="Poco::Net::SocketAcceptor::unregisterAcceptor()">unregisterAcceptor</a></p>
<h2>Constructors</h2>
<h3><a name="15087">SocketAcceptor</a> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">explicit <a href="Poco.Net.SocketAcceptor.html" title="class Poco::Net::SocketAcceptor">SocketAcceptor</a>(<br />&nbsp;&nbsp;&nbsp;&nbsp;<a href="Poco.Net.ServerSocket.html" title="class Poco::Net::ServerSocket">ServerSocket</a> &amp; socket<br />);</p>
<div class="description">
<p>Creates an <a href="Poco.Net.SocketAcceptor.html" title="class Poco::Net::SocketAcceptor">SocketAcceptor</a>, using the given <a href="Poco.Net.ServerSocket.html" title="class Poco::Net::ServerSocket">ServerSocket</a>. </p>
</div>
<h3><a name="15089">SocketAcceptor</a> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl"><a href="Poco.Net.SocketAcceptor.html" title="class Poco::Net::SocketAcceptor">SocketAcceptor</a>(<br />&nbsp;&nbsp;&nbsp;&nbsp;<a href="Poco.Net.ServerSocket.html" title="class Poco::Net::ServerSocket">ServerSocket</a> &amp; socket,<br />&nbsp;&nbsp;&nbsp;&nbsp;<a href="Poco.Net.SocketReactor.html" title="class Poco::Net::SocketReactor">SocketReactor</a> &amp; reactor<br />);</p>
<div class="description">
<p>Creates an <a href="Poco.Net.SocketAcceptor.html" title="class Poco::Net::SocketAcceptor">SocketAcceptor</a>, using the given <a href="Poco.Net.ServerSocket.html" title="class Poco::Net::ServerSocket">ServerSocket</a>. The <a href="Poco.Net.SocketAcceptor.html" title="class Poco::Net::SocketAcceptor">SocketAcceptor</a> registers itself with the given <a href="Poco.Net.SocketReactor.html" title="class Poco::Net::SocketReactor">SocketReactor</a>. </p>
</div>
<h2>Destructor</h2>
<h3><a name="15092">~SocketAcceptor</a> <img src="images/virtual.gif" alt="virtual" title="virtual" style="vertical-align:baseline;" border="0" />  <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">virtual ~<a href="Poco.Net.SocketAcceptor.html" title="class Poco::Net::SocketAcceptor">SocketAcceptor</a>();</p>
<div class="description">
<p>Destroys the <a href="Poco.Net.SocketAcceptor.html" title="class Poco::Net::SocketAcceptor">SocketAcceptor</a>. </p>
</div>
<h2>Member Functions</h2>
<h3><a name="15096">onAccept</a> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">void onAccept(<br />&nbsp;&nbsp;&nbsp;&nbsp;<a href="Poco.Net.ReadableNotification.html" title="class Poco::Net::ReadableNotification">ReadableNotification</a> * pNotification<br />);</p>
<div class="description">
<p></p>
</div>
<h3><a name="15093">registerAcceptor</a> <img src="images/virtual.gif" alt="virtual" title="virtual" style="vertical-align:baseline;" border="0" />  <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">virtual void registerAcceptor(<br />&nbsp;&nbsp;&nbsp;&nbsp;<a href="Poco.Net.SocketReactor.html" title="class Poco::Net::SocketReactor">SocketReactor</a> &amp; reactor<br />);</p>
<div class="description">
<p>Registers the <a href="Poco.Net.SocketAcceptor.html" title="class Poco::Net::SocketAcceptor">SocketAcceptor</a> with a <a href="Poco.Net.SocketReactor.html" title="class Poco::Net::SocketReactor">SocketReactor</a>. </p>
<p>A subclass can override this and, for example, also register an event handler for a timeout event. </p>
<p>The overriding method must call the baseclass implementation first. </p>
</div>
<h3><a name="15095">unregisterAcceptor</a> <img src="images/virtual.gif" alt="virtual" title="virtual" style="vertical-align:baseline;" border="0" />  <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">virtual void unregisterAcceptor();</p>
<div class="description">
<p>Unregisters the <a href="Poco.Net.SocketAcceptor.html" title="class Poco::Net::SocketAcceptor">SocketAcceptor</a>. </p>
<p>A subclass can override this and, for example, also unregister its event handler for a timeout event. </p>
<p>The overriding method must call the baseclass implementation first. </p>
</div>
<h3><a name="15098">createServiceHandler</a> <img src="images/protected.gif" alt="protected" title="protected" style="vertical-align:baseline;" border="0" />  <img src="images/virtual.gif" alt="virtual" title="virtual" style="vertical-align:baseline;" border="0" />  <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">virtual ServiceHandler * createServiceHandler(<br />&nbsp;&nbsp;&nbsp;&nbsp;<a href="Poco.Net.StreamSocket.html" title="class Poco::Net::StreamSocket">StreamSocket</a> &amp; socket<br />);</p>
<div class="description">
<p>Create and initialize a new ServiceHandler instance. </p>
<p>Subclasses can override this method. </p>
</div>
<h3><a name="15100">reactor</a> <img src="images/protected.gif" alt="protected" title="protected" style="vertical-align:baseline;" border="0" />  <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl"><a href="Poco.Net.SocketReactor.html" title="class Poco::Net::SocketReactor">SocketReactor</a> * reactor();</p>
<div class="description">
<p>Returns a pointer to the <a href="Poco.Net.SocketReactor.html" title="class Poco::Net::SocketReactor">SocketReactor</a> where this <a href="Poco.Net.SocketAcceptor.html" title="class Poco::Net::SocketAcceptor">SocketAcceptor</a> is registered. </p>
<p>The pointer may be null. </p>
</div>
<h3><a name="15101">socket</a> <img src="images/protected.gif" alt="protected" title="protected" style="vertical-align:baseline;" border="0" />  <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl"><a href="Poco.Net.Socket.html" title="class Poco::Net::Socket">Socket</a> &amp; socket();</p>
<div class="description">
<p>Returns a reference to the <a href="Poco.Net.SocketAcceptor.html" title="class Poco::Net::SocketAcceptor">SocketAcceptor</a>'s socket. </p>
</div>
<p class="footer">POCO C++ Libraries 1.3.6-all<br />
Copyright &copy; 2009, <a href="http://pocoproject.org/" target="_blank">Applied Informatics Software Engineering GmbH and Contributors</a></p>

</div>
</body>
</html>