<doc>
	<legacy_id>1840</legacy_id>
	<name>write to socket</name>
	<type>command</type>

	<syntax>
		<example>write <i>value</i> to socket <i>socket</i> [with message <i>callbackMessage</i>]</example>
	</syntax>

	<synonyms>
	</synonyms>

	<summary>Sends data to a <glossary tag="socket">socket</glossary>.</summary>

	<examples>
<example>write "test" to socket "127.0.0.0:21"</example>
<example>write "test" &amp; linefeed to socket "www.google.com:80"</example>
<example><p>on mouseUp</p><p>   open socket "www.google.com:80"</p><p>   write "test" to socket "www.google.com:80" with message "socketFinishedWriting"</p><p>end mouseUp</p><p>      </p><p>on socketFinishedWriting pSocketID</p><p>   put "Data written to socket" &amp;&amp; pSocketID</p><p>   close socket "www.google.com:80"</p><p>end socketFinishedWriting</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="arrayEncode">arrayEncode Function</function>
		<command tag="accept">accept Command</command>
		<command tag="write to driver">write to driver Command</command>
		<command tag="post">post Command</command>
		<message tag="socketTimeout">socketTimeout Message</message>
	</references>

	<description>Use the <b>write to socket</b> <glossary tag="command">command</glossary> to send data to another system via a <glossary tag="TCP">TCP</glossary> <glossary tag="socket">socket</glossary>.<p></p><p><b>Parameters:</b></p><p>The <i>value</i> is any <glossary tag="expression">expression</glossary> that <glossary tag="evaluate">evaluates</glossary> to a <keyword tag="string">string</keyword>.</p><p></p><p>The <i>socketID</i> is the identifier (set when you opened the <glossary tag="socket">socket</glossary>) of the <glossary tag="socket">socket</glossary> you want to send data to. The socket identifier starts with the <glossary tag="IP address">IP address</glossary> of the <glossary tag="disabled">host</glossary> the <glossary tag="socket">socket</glossary> is connected to, and may optionally include a <glossary tag="port">port number</glossary> (separated from the <glossary tag="IP address">IP address</glossary> by a colon). If there is more than one <glossary tag="socket">socket</glossary> connected to that <glossary tag="disabled">host</glossary> and <glossary tag="port">port</glossary>, you can specify which <glossary tag="socket">socket</glossary> by <glossary tag="append">appending</glossary> the connection name or number that was assigned when the <glossary tag="socket">socket</glossary> was opened, separated from the <glossary tag="port">port</glossary> number by a vertical bar (|).</p><p></p><p>The <i>callbackMessage</i> is the name of a <keyword tag="message box">message</keyword> to be sent to the current <glossary tag="object">object</glossary> when the write is successfully completed.</p><p></p><p><b>Comments:</b></p><p>If you specify a <i>callbackMessage</i>, as soon as the write is finished, the specified <keyword tag="message box">message</keyword> is sent to the <glossary tag="object">object</glossary> whose <property tag="script">script</property> contains the <b>write to socket</b> <glossary tag="command">command</glossary>. The <i>callbackMessage</i> is sent with one <glossary tag="parameter">parameter</glossary>, which is the <i>socketID</i>.</p><p></p><p>If you don't specify a <i>callbackMessage</i>, the <glossary tag="handler">handler</glossary> pauses until the write has been completed, or until the time set in the <property tag="socketTimeoutInterval">socketTimeoutInterval</property> <glossary tag="property">property</glossary> has passed.</p></description>
</doc>