Talk:Parse an IP Address: Difference between revisions

Add comment about port 0.
(Add comment about port 0.)
Line 23:
::: Ah, I see now. I only saw the output format of the task to be relevant in that it required comprehension of the input format to generate. The internal representation (in particular, correct distinction of host and port addresses) was what I was more interested in. Requiring the port address in the output helps a reviewer understand how the port number was understood. Change the requirements for the output format however you see fit, with that requirement in mind. (I'd try changing it, but I've been without my glasses for a week, and doing things on the computer has been very, very error-prone--even trying to write coherently. )--[[User:Short Circuit|Michael Mol]] 15:15, 28 September 2011 (UTC)
 
=== Port 0 ===
The 'bit specifying if port was given' doesn't seem necessary, how about just use port 0? --[[User:Ledrug|Ledrug]] 15:37, 28 September 2011 (UTC)
: Specifying port 0 means "any available", but only in some contexts. A more general solution should be preferred, IMO. I took the "bit specifying" bit as "an indicator", rather than as an explicit like-formatted boolean bit. The way I read it, it could be equally (and possibly more clearly) written as "a note specifying if port was given". --[[User:Short Circuit|Michael Mol]] 15:40, 28 September 2011 (UTC)
Line 34 ⟶ 35:
:::::: So the "In languages where variant result types are clumsy" bit is about how an example represents data internally, then. I think I understand, then. Not certain it's necessary, though. In answer to your question, the address would probably be represented using something like a [http://msdn.microsoft.com/en-us/library/windows/desktop/ms737530(v=VS.85).aspx sockaddr] structure.--[[User:Short Circuit|Michael Mol]] 16:48, 28 September 2011 (UTC)
::::::: I do not believe sockaddr distinguishes between port 0 and default port (which makes that particular issue a sore subject -- this design decision pushes complexity into the surrounding context). --[[User:Rdm|Rdm]] 16:59, 28 September 2011 (UTC)
 
: TCP and UDP never use port 0. Sockets use port 0 to mean "port not specified". The meaning of "port not specified" changes with context. With a server socket, during a bind() to "port not specified", system chooses a default port in range 49152 to 65535. With a server socket, port 0 is same as "port not specified". --[[User:Kernigh|Kernigh]] 22:13, 28 September 2011 (UTC)
Anonymous user