title: read string datastream in Flink from socket without using netcat server
body: <p>I have a case scenario in which I have a stream generator <strong>client</strong> which is generating multiple streams, merging them and sending it to socket and I want Flink program to listen to it as the <strong>server</strong>. As we know that server has to be turned up first, so that it can listen to client requests. I tried to do the same by using code given below</p>
  
  <pre><code> public static void main(String[] args)  throws Exception {
  
      //setting the envrionment variable as StreamExecutionEnvironment
        StreamExecutionEnvironment environment = StreamExecutionEnvironment.getExecutionEnvironment();
  
          environment.setParallelism(1);
  
  
          DataStream&lt;String&gt; stream1 = environment.socketTextStream("localhost", 9000);
          stream1.print();
  
  
  
                  //start the execution
       environment.execute(" Started the execution ");
  
  
  
  }// main
  </code></pre>
  
  <p>The code for stream generator acting as client is given below</p>
  
  <pre><code>    DataStream&lt;Event&gt; stream1  = envrionment
                  .addSource(new EventGenerator(2,60,1,1,100, 200 ))
                  .name("stream 1")
                  .setParallelism(parallelism_for_stream_rr);
  
      DataStream&lt;Event&gt; stream2  = envrionment
              .addSource(new EventGenerator(3,60,1,2,10, 20 ))
              .name("stream 2")
              .setParallelism(parallelism_for_stream_rr);
  
  
      DataStream&lt;Event&gt; stream3  = envrionment
              .addSource(new EventGenerator(5,60,1,3,30, 40 ))
              .name("stream 3")
              .setParallelism(parallelism_for_stream_rr);
  
  
      DataStream&lt;Event&gt; merged = stream1.union(stream2,stream3);
  
      merged.print();
  
  
  
              // sending data to Mobile Cep via socket
  
              merged.map(new MapFunction&lt;Event, String&gt;() {
  
                  @Override
                  public String map(Event event) throws Exception {
                      String tuple = event.toString();
  
  
                      return tuple + "\n";
  
                  }
              }).writeToSocket("localhost", 9000, new SimpleStringSchema() );
  </code></pre>
  
  <p>Issue # 1: The issue is that client code works only when I start a Netcat server, but then Netcat server doesn't forwards the data streams.If Netcat server is not up, client code says it cant make a connection</p>
  
  <p>Issue # 2: Flink program doesn't execute if Netcat server is not up</p>
  
  <pre><code>Caused by: java.net.ConnectException: Connection refused (Connection refused)
  at java.net.PlainSocketImpl.socketConnect(Native Method)
  at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
  at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
  at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
  at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
  </code></pre>
  
  <p>I know that one possible solution for this is to generate the streams within the Flink program, but I want to receive the streams via socket.</p>
  
  <p>Thanks in Advance ~</p>