In order to retrieve peer IP and port, you usually need to call Socket.unpack_sockaddr_in(get_peername), but I noticed that it leads to sporadic crashes because get_peername returns nil in callbacks like post_init or even in receive_data.
Is that an expected behavior? If so, what callback would be the right place to save the peername in an instance variable?