title: stream_context_create bind to host / subdomain?
body: <p>I am using <a href="http://php.net/manual/en/function.stream-context-create.php" rel="nofollow"><code>stream_context_create</code></a> to bind php to an ip address already, but I would also like to bind it to a subdomain / host as well. Here is my code, which is working ...</p>
  
  <p>The <code>$host</code> variable is to an mx record to a partner company's server, they want me to connect to it with a certain ip on my server, which works, but also want it to verify the subdomain as well.</p>
  
  <pre><code>$socket_options = array('socket' =&gt; array('bindto' =&gt; $this-&gt;ipaddress . ':0'));
  $socket_context = stream_context_create($socket_options);
  $this-&gt;smtp_conn = stream_socket_client($host . ':' . $port, $errno,
  $errstr, $tval, STREAM_CLIENT_CONNECT, $socket_context);
  </code></pre>
  
  <p>I tried adding this to the $socket_options, but no luck - where <code>$this-&gt;Host</code> is my subdomain.</p>
  
  <pre><code>'http' =&gt; array('header' =&gt; "Host: " . $this-&gt;Host)
  </code></pre>
  
  <p>Is this even possible? I never heard of this being done before. Thanks.</p>