I’m writing a program which connects to a similar program on another computer; right now my desktop connects to my laptop. Both have IPv4 and IPv6 addresses; the IPv4 address is local-only, while the IPv6 address is globally visible but occasionally changes because of the weather. The program tries all the addresses it gets from getalladdrinfo
until it gets a successful connection, then passes the connection to a task, which sends and receives messages on the connection. Within the past hour or two, the IPv6 addresses have changed. The program keeps saying “closed” and transferring nothing. Having recently changed something in connectionTask
, I investigated but found out that what I changed was not the culprit, it was being passed a closed socket. Here are some @info
outputs from the latest run:
julia> whichEar=64
┌ Info: dest
└ d = ip"2001:5b0:2172:b3f8:b32:42db:86ab:352f"
┌ Info: connectTask
│ dest =
│ 2-element Vector{Sockets.IPAddr}:
│ ip"2001:5b0:2172:b3f8:b32:42db:86ab:352f"
│ ip"192.168.42.201"
└ sock = Sockets.TCPSocket(RawFD(25) open, 0 bytes waiting)
┌ Info: connectionTask
└ conn = EANetwork.Connection(Sockets.TCPSocket(RawFD(-1) closed, 0 bytes waiting), UInt8[], UInt8[], 0, -1, 0.5784105585570988, 0x003d51d05cd98be6, 0x003d51d0349fe157, true, false, false, Message(<snip>), Message(<snip>))
closed
whichear=64
is output by the program and means that it’s listening on only an IPv6 socket; I’m running Linux and IPv6 sockets can handle IPv4 connections as well. If I were running this on BSD, whichear
would be 80, if what I remember from trying to program network sockets over a decade ago still applies.
The snipped stuff is an empty message. What’s in the Message
struct is irrelevant to the question.
The times indicate that 675 ms elapsed between creating the Connection
with the socket in it and the last activity, which appears to have been saying hello.
Should I wait a second before checking whether the socket is open, or how should I check?