title: Reading and Writing From Same Socket in Flink / Kafka
body: <p>Good Day</p>
  
  <p>I am receiving data (stream data) through flink/kafka.
  The port I am connecting to is the same port I need to write a message back to</p>
  
  <p>TCP/IP -> Flink/Kafka Consumer -> Process Data -> Send Result to kafka topic and back to TCP/IP connection</p>
  
  <pre><code>// 1. Connect to TCP Stream (TCP (Socket) -&gt; Kafka Stream INPUT)
  val consumer_stream = env.socketTextStream(url, port, '\n')
  
  // 2. Processing Data
  .....
  
  // 3. Write result to kafka topic 
  consumer_stream.addSink(new FlinkKafkaProducer09[String](broker_url, topic_name, new SimpleStringSchema()))
  
  // 4. Send result back to connected url ie.(Ref Step 1 URL) (url+port)
  (This is where I need Assistance)
  </code></pre>
  
  <p>Connecting to URL and port works. I receive and process the data
  I write to the topic
  Now I also need to write back to the same url and port that I am connected to.{Since the Url and Port can send and receive data at the same time}</p>
  
  <p>I got it to write to another port</p>
  
  <pre><code>// write to Different PORT
  val socket_write: DataStreamSink[String] = out_data.writeToSocket(url, diff_port, new SimpleStringSchema())
  </code></pre>
  
  <p>This works... The problem is trying to write to the same port. When I use the same port that I am reading in from... The flink job fails</p>
  
  <p>Any Ideas</p>
  
  <p>Regards</p>