Developers.Refactor.Host: Difference between revisions
(Importing page from Tikiwiki) |
m (1 revision) |
Latest revision as of 20:09, 20 June 2009
IP Addresses and Port Numbers
Shareaza deals with IP addresses and port numbers a lot. Many methods pass them to one another, and different parts of the Windows platform expect them in different forms. Here's a summary of how IP addresses and port numbers are expressed in the Shareaza code.
IN_ADDR Windows Sockets 2 [1] contains just an IP address
<source lang="c"> BOOL CConnection::ConnectTo(IN_ADDR* pAddress, WORD nPort) </source>
SOCKADDR_IN MFC [2] contains an IP address and port number
<source lang="c"> BOOL CConnection::ConnectTo(SOCKADDR_IN* pHost) </source>
Note that even though these are big complicated strucures, they are just telling us 1.2.3.4:5. They don't contain a socket or any methods, for instance.
What I want to program into Shareaza is an object to replace all this and make it easier. There would just be one member variable, 6 bytes of memory to hold the IP address and port number There would then be a ton of methods to read and write the address, different parts of it, and the port number There would also be methods to have it immediately spit out its contents as a string, or copy it into a IN_ADDR structure or SOCKADDR_IN structure for a windows call.
called CNetAddress or whatever