listenAddr is an address , i.e. contains IP+port number
listener is only a port number
discovery is also port number for finding new peers
The word listener
has a meaning of a connecting gate, for example,this is another piece of ethereum's source ('node/node.go'):
ipcListener net.Listener // IPC RPC listener socket to serve API requests
httpListener net.Listener // HTTP RPC listener socket to server API requests
wsListener net.Listener // Websocket RPC listener socket to server API requests
In Go
Listener
is a standard type:
A Listener is a generic network listener for stream-oriented protocols.
Multiple goroutines may invoke methods on a Listener simultaneously.
type Listener interface {
// Accept waits for and returns the next connection to the listener.
Accept() (Conn, error)
// Close closes the listener.
// Any blocked Accept operations will be unblocked and return errors.
Close() error
// Addr returns the listener's network address.
Addr() Addr
}
This is the meaning of the word listener
, but ListenAddr
is the full address of the socket. it is defined in Linux kernel as this struct:
#include <netinet/in.h>
struct sockaddr_in {
short sin_family; // e.g. AF_INET
unsigned short sin_port; // e.g. htons(3490)
struct in_addr sin_addr; // see struct in_addr, below
char sin_zero[8]; // zero this if you want to
};
The fields sin_addr
and sin_port
together is the variable listenAddr
, in fact, this is what the method Addr()
should return.
But in Ethereum code, by saying listener
they don't refer to the Interface listener
nor the object that implements listener interface, they refer to the port number
.