On Thu, Aug 19, 2021 at 10:50 AM Eric Blake <ebl...@redhat.com> wrote:
> On Wed, Aug 18, 2021 at 10:24:52AM -0400, John Snow wrote: > > > > > > > > + @upper_half > > > > + @require(Runstate.IDLE) > > > > + async def accept(self, address: Union[str, Tuple[str, int]], > > > > + ssl: Optional[SSLContext] = None) -> None: > > > > + """ > > > > + Accept a connection and begin processing message queues. > > > > + > > > > + If this call fails, `runstate` is guaranteed to be set back > to > > > `IDLE`. > > > > + > > > > + :param address: > > > > + Address to listen to; UNIX socket path or TCP > address/port. > > > > > > Can't TCP use a well-known port name instead of an int? But limiting > > > clients to just int port for now isn't fatal to the patch. > > > > > > > > The old QMP library didn't support this, and I used the old library as my > > template here. I'm willing to change the address format and types to be > > more comprehensive, but I was thinking that it should probably try to > match > > or adhere to some standard; de-facto or otherwise. I wasn't sure which to > > pick, and we use a few different ones in QEMU itself. Any recommendations > > for me? > > I asked because I know QAPI specifies TCP as string/string (the > hostname as a string makes absolute sense, but the port number as a > string is because of the less-used feature of a well-known port name). > I'm fine if the initial patch uses an int for the port number here; we > can always add support for more formats down the road when someone > actually has a use for them. > > https://docs.python.org/3/library/socket.html#socket-families "A pair (host, port) is used for the AF_INET address family, where host is a string representing either a hostname in Internet domain notation like ' daring.cwi.nl' or an IPv4 address like '100.50.200.5', and port is an integer." The docs seem to suggest that I am actually limited only to integers here. Do you have an example of using a string for a port number? I have to admit I am not well acquainted with it.