Re: [akka-user] Re: [akka-streams] Trying to mimic socket level programming , connect client and then send data if connection is available

2016-08-01 Thread murtuza chhil
Hi Konrad, The Source> clientSource = Source.maybe(); does the trick, don't see a disconnect on the netcat server send. Also figured, I shouldn't be running the graph multiple times once to connect and the second time to send data. Once its run, any

Re: [akka-user] Re: [akka-streams] Trying to mimic socket level programming , connect client and then send data if connection is available

2016-08-01 Thread Konrad Malawski
Source.single completes the stream (closes the connection) once it has signalled the data. Simply put a Source.maybe behind it (a.concat(b)) or use a different source, like unfold or an iterator). -- Konrad `ktoso` Malawski Akka @ Lightbend On 1 August

[akka-user] Re: [akka-streams] Trying to mimic socket level programming , connect client and then send data if connection is available

2016-08-01 Thread murtuza chhil
Hi Johan, Thank you very much. Yes indeed stream + tcp is hurting me for sure and I have tried reading the docs and sample code over and over. So yes, I made some progress. Please ignore the verbosity of the code, I just need to familiarize myself with return values and look at the source of

[akka-user] Re: [akka-streams] Trying to mimic socket level programming , connect client and then send data if connection is available

2016-08-01 Thread Johan Andrén
Hi Chhil, The flow returned by outgoingConnection materializes into a CompletionStage which will be failed if the connection fails, so that is where you can implement your error handling for the initial connection. You would have to keep the materialized value when you construct the flow