title: Writing Spark Streaming Output to a Socket
body: <p>I have a DStream "Crowd" and I want to write each element in "Crowd" to a socket. When I try to read from that socket, it dosen't print anything. I am using following line of code:</p>
  
  <pre><code>val server = new ServerSocket(4000,200);
  val conn = server.accept()
  val out = new PrintStream(conn.getOutputStream());
  crowd.foreachRDD(rdd =&gt; {rdd.foreach(record=&gt;{out.println(record)})})
  </code></pre>
  
  <p>But if use (this is not I want though): </p>
  
  <pre><code>crowd.foreachRDD(rdd =&gt; out.println(rdd)) 
  </code></pre>
  
  <p>It does write something to the socket. </p>
  
  <p>I suspect there is a problem with using rdd.foreach(). Although it should work. I am not sure what I am missing.</p>