Hi Mike,

The problem is that you create one outgoing connection, but you cannot use 
that more than once. If you move that logic to create a new outgoing 
connection on every new incoming it will work better, so that would be 
inside of your foreach.

Please take a look at the docs for doing IO with Streams 
here: 
http://doc.akka.io/docs/akka/2.4.4/scala/stream/stream-io.html#Streaming_TCP 
(I think that will answer most of your questions)

--
Johan Andrén
Akka Team, Lightbend Inc.

On Tuesday, April 19, 2016 at 5:44:27 PM UTC+2, Mike Limansky wrote:
>
> Hi all,
>
>   I'm very new to Akka Streams, trying to get the ideas behind the streams 
> and how to use them. I'd like to make a very simple thing: to connect two 
> TCP server sockets, but I get stuck with that.
>
>   If I have server and client connections, it more or less clear for me:
>
>   val conn = Tcp().bind("localhost", 1234)
>   val out = Tcp().outgoingConnection("localhost", 2345)
>  
>
>   val handler = Sink.foreach[Tcp.IncomingConnection] { c =>
>
>     println("Got connection from " + c.remoteAddress)
>
>     c.handleWith(out)
>
>   }
>
>   conn.to(handler).run()
>
>
>   This working for one connection. Could anybody give me a clue how to get 
> it work with more that one incoming connections (I suppose I need to use 
> Merge, or Source.combine)?
>
>   And the second question. As I understand this works in one direction 
> (from server socket to client). How can I use BidiFlow in such situation?
>
>   Finally, If I have two server connections I have no idea how to achieve 
> same result. Should I use mutable state to store incoming connections?
>  
> --
> BR,
> Mike.
>

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to