To cleanly close a socket, use `close(::TCPSocket)`. Also, you might want to check `isopen(::TCPSocket)` as the loop condition.
(the applicable version of `close` in the method table is `close(::AsyncStream)`, because TCPSocket <: AsyncStream) On Tue, Dec 23, 2014 at 7:52 AM, Ben Arthur <[email protected]> wrote: > i'm able to setup a connection and pass messages, the problem is that when > the sender is another julia process, and that process exits, the receiver > is spammed with an infinite number of empty lines. how does one exit > cleanly? is there a disconnect() command? code below. thanks > > ========== first do this in one julia process ========== > julia> @async begin > server = listen(2001) > while true > sock = accept(server) > @async while true > println(strftime(time())*": "*readline(sock)) > end > end > end > > Task (waiting) @0x00007fb9e7803480 > > julia> Tue Dec 23 07:43:28 2014: foo > Tue Dec 23 07:43:29 2014: > Tue Dec 23 07:43:35 2014: > Tue Dec 23 07:43:35 2014: > Tue Dec 23 07:43:35 2014: > Tue Dec 23 07:43:35 2014: > > > > ========== then do this in a second julia process ====== > julia> sock = connect(2001) > TCPSocket(open, 0 bytes waiting) > > julia> println(sock,"foo") > > julia> <ctrl-D> # note all the output in the process above following this >
