<doc>
	<legacy_id>1099</legacy_id>
	<name>accept</name>
	<type>command</type>

	<syntax>
		<example>accept [datagram] connections on port <i>number</i> with message <i>callbackMessage</i></example>
	</syntax>

	<synonyms>
	</synonyms>

	<summary>Accepts an internet connection and creates a <glossary tag="socket">socket</glossary> for that connection.</summary>

	<examples>
<example>accept connections on port 80 with message "connectionMade"</example>
<example><font face="courier new" size="17">accept datagram connections on port 80 with message "</font>connectionMade<font face="courier new" size="17">"</font></example>
<example><p>on mouseUp</p><p>   accept connections on port 80 with message "connectionMade"</p><p>end mouseUp</p><p></p><p>on connectionMade pIPAddress</p><p>   put "Connection made:" &amp;&amp; pIPAddress</p><p>end connectionMade</p></example>
	</examples>

	<history>
		<introduced version="1.0">Added.</introduced>
		<deprecated version=""></deprecated>
		<removed version=""></removed>
		
		<experimental version=""></experimental>
		<nonexperimental version=""></nonexperimental>
	</history>

	<objects>
	</objects>

	<platforms>
		<mac/>
		<windows/>
		<linux/>
	</platforms>

	<classes>
		<desktop/>
		<server/>
		<web/>
	</classes>

	<security>
		<network/>
	</security>


	<classification>
		<category>Networks &amp; Communication</category>
	</classification>

	<references>
		<function tag="hostNameToAddress">hostNameToAddress Function</function>
		<function tag="openSockets">openSockets Function</function>
		<function tag="peerAddress">peerAddress Function</function>
		<function tag="hostAddress">hostAddress Function</function>
		<function tag="hostAddressToName">hostAddressToName Function</function>
		<function tag="hostName">hostName Function</function>
		<command tag="close socket">close socket Command</command>
		<command tag="open socket">open socket Command</command>
		<command tag="read from socket">read from socket Command</command>
		<command tag="write to socket">write to socket Command</command>
		<property tag="HTTPProxy">HTTPProxy Property</property>
	</references>

	<description>Use the <b>accept</b> <glossary tag="command">command</glossary> when running a <glossary tag="server">server</glossary>, to accept <glossary tag="TCP">TCP</glossary> connections or <glossary tag="UDP">UDP</glossary> <glossary tag="datagram">datagrams</glossary> from other systems (or other <glossary tag="process">processes</glossary> on the same system).<p>Use the datagram option if you want to accept UDP datagrams.</p><p></p><p><b>Parameters:</b></p><p>The <i>portNumber</i> is the <glossary tag="TCP">TCP</glossary> <glossary tag="port">port</glossary> number on which to accept connections.</p><p>The <i>callbackMessage</i> is the name of a <keyword tag="message box">message</keyword> to be sent when a connection is made or a <glossary tag="datagram">datagram</glossary> is received.</p><p></p><p><b>Comments:</b></p><p>When a connection is made or a datagram is received, the <b>accept</b> <glossary tag="command">command</glossary> creates a new <glossary tag="socket">socket</glossary> that can be used to communicate with the other system (or <glossary tag="process">process</glossary>). When using the <command tag="close socket">close socket</command>, <command tag="read from socket">read from socket</command>, or <command tag="write to socket">write to socket</command> <glossary tag="command">commands</glossary>, you can refer to this <glossary tag="socket">socket</glossary> with a socket identifier that looks like this:</p><p><i>host</i>:<i>port</i>[|<i>connectionID</i>]</p><p>where the <i>connectionID</i> is a number assigned by the <b>accept</b> <glossary tag="command">command</glossary>. (You only need to specify the connection number if there is more than one <glossary tag="socket">socket</glossary> connected to a particular <glossary tag="port">port</glossary> and <glossary tag="disabled">host</glossary>.)</p><p></p><p>The <i>callbackMessage</i> is sent to the <glossary tag="object">object</glossary> whose <property tag="script">script</property> contains the <b>accept</b> <glossary tag="command">command</glossary>. Either one or two <glossary tag="parameter">parameters</glossary> are sent with this <keyword tag="message box">message</keyword>. The first <glossary tag="parameter">parameter</glossary> is the <glossary tag="IP address">IP address</glossary> of the system or <glossary tag="process">process</glossary> making the connection. If a <glossary tag="datagram">datagram</glossary> is being accepted, the second <glossary tag="parameter">parameter</glossary> is the contents of the <glossary tag="datagram">datagram</glossary>.</p><p></p><p>For technical information about sockets, see RFC 147 at &lt;<u>http://www.ietf.org/rfc/rfc147.txt</u>&gt;.</p><p>For technical information about UDP datagrams, see RFC 768 at &lt;<u>http://www.ietf.org/rfc/rfc0768.txt</u>&gt;.</p><p>For technical information about the numbers used to designate standard ports, see the list of port numbers at &lt;<u>http://www.iana.org/assignments/port-numbers</u>&gt;<i>,</i> in particular the section entitled "Well Known Port Numbers".</p></description>
</doc>