When I see right, you can specify only the port where amule accepts EC, not the port amuleweb listens on commandline.
From amuleweb man page:
-s, --server-port=
Webserver's HTTP port. This is the port you can point your browser to (default: 4711)
So I think that port is in amule.conf or remote.conf. So amule can see which port he has to check.
Well, remote.conf... which user? Amuleweb can be run by any user, not necessarily by the one who runs amule. The only requirement is that (s)he: 1) has an appropriate remote.conf file (or any other name, see the -f, --config-file command-line option), 2) supplies adequate command-line parameters, 3) answers the questions from amuleweb.
Actually, it could be implemented:
1) amule check for a process with a command name "amuleweb{DLG}"
2) check the command-line of the process for a -s switch
3) if not found, get the owner of the process
4) if owner of the process is not the current user, and we are not root, then give up
5) check the command-line of the process for a -f switch, if not found use "remote.conf" as config file name
6) read config file from the detected user's home directory.
I think it 1) doesn't wort the effort, 2) opens security holes, 3) people used to not like when a process just reads their secret files without a notice.
If you disagree with the above, just let me know :)
PS: And we still didn't care about things like:
1) what if a user renames amuleweb to something else, just for fun? (like amule-webserver, and leaves amuleweb as a symlink to the new name)
2) what if I use amuleweb to monitor another amule(d) somewhere else?
3) amuleweb behaves differently when started manually, manually with the -L switch, automatically...
So, certain cases can be detected, but it's more error-prone than useful.