<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.nsnam.org/mediawiki/index.php?action=history&amp;feed=atom&amp;title=HOWTO_use_null_callbacks</id>
	<title>HOWTO use null callbacks - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.nsnam.org/mediawiki/index.php?action=history&amp;feed=atom&amp;title=HOWTO_use_null_callbacks"/>
	<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=HOWTO_use_null_callbacks&amp;action=history"/>
	<updated>2026-05-05T09:42:49Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.8</generator>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=HOWTO_use_null_callbacks&amp;diff=2771&amp;oldid=prev</id>
		<title>Jpelkey: New page: {{TOC}}  Sometimes the API in use may require a callback; however, for your particular function, you may not wish to provide one.  In this case, it is possible to provide a null callback. ...</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=HOWTO_use_null_callbacks&amp;diff=2771&amp;oldid=prev"/>
		<updated>2009-05-22T13:35:46Z</updated>

		<summary type="html">&lt;p&gt;New page: {{TOC}}  Sometimes the API in use may require a callback; however, for your particular function, you may not wish to provide one.  In this case, it is possible to provide a null callback. ...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{TOC}}&lt;br /&gt;
&lt;br /&gt;
Sometimes the API in use may require a callback; however, for your particular function, you may not wish to provide one.  In this case, it is possible to provide a null callback.&lt;br /&gt;
&lt;br /&gt;
== HOWTO use null callbacks ==&lt;br /&gt;
&lt;br /&gt;
To use a null callback, use the ns3::MakeNullCallback construct:&lt;br /&gt;
&lt;br /&gt;
    template&amp;lt;typename R&amp;gt;&lt;br /&gt;
    Callback&amp;lt; R, T1, T2, T3, T4, T5, T6 &amp;gt; ns3::MakeNullCallback (void)&lt;br /&gt;
&lt;br /&gt;
Example usage: The ns3::Socket class uses callbacks to indicate completion of events such as a successful TCP connect(). These callbacks are set in the following function:&lt;br /&gt;
&lt;br /&gt;
    void Socket::SetConnectCallback (Callback&amp;lt;void, Ptr&amp;lt;Socket&amp;gt; &amp;gt; connectionSucceeded,&lt;br /&gt;
                           Callback&amp;lt;void, Ptr&amp;lt;Socket&amp;gt; &amp;gt; connectionFailed,&lt;br /&gt;
                           Callback&amp;lt;void, Ptr&amp;lt;Socket&amp;gt; &amp;gt; halfClose);&lt;br /&gt;
&lt;br /&gt;
But suppose you do not care about registering a callback for the halfClose event (but you want to register one for the connectionSucceeded and connectionFailed cases). In that case, you can pass a null callback as the third argument. You just need to pass a callback with the matching signature, as follows:&lt;br /&gt;
&lt;br /&gt;
    localSocket-&amp;gt;SetConnectCallback (&lt;br /&gt;
    MakeCallback (&amp;amp;ConnectionSucceededCallback),&lt;br /&gt;
    MakeCallback (&amp;amp;ConnectionFailedCallback),&lt;br /&gt;
    MakeNullCallback&amp;lt;void, Ptr&amp;lt;Socket&amp;gt; &amp;gt; () );&lt;/div&gt;</summary>
		<author><name>Jpelkey</name></author>
	</entry>
</feed>