Feature #482
TcpSocket should be able to listen on specific IP
Status: | Approved | Start date: | 05/30/2013 | |
---|---|---|---|---|
Priority: | Normal | Due date: | ||
Assignee: | Jan Dolinár | % Done: | 100% | |
Category: | Core | Spent time: | - | |
Target version: | - |
Description
TcpSocket::Listen should take optional parameter that would allow it to listen on specific IP address, e.g. only on localhost. Default should still be listen to any traffic (0.0.0.0 or ::).
Two patches are attached, first implements the functionality described above, second uses it in Skylark (which is the reason why I started with this ;) ). I'm not 100% happy with those patches, but they do work well. What is IMHO missing is some class that would make it simpler to a) pass IPv4 and IPv6 and b) provide some utility functions to provide simple conversion of IP addresses from/to string. The current use of IpAddrInfo in the skylark.patch is definitely not nice nor readable.
Also, the IPv6 code in TcpSocket::Listen() was not entirely correct, so I improved it as well.
Mirek, can you please look at it when you get some spare time? Thanks.
History
#1 Updated by Miroslav Fidler almost 12 years ago
- Status changed from Patch ready to Ready for QA
- Assignee changed from Miroslav Fidler to Jan Dolinár
Added variant with IpAddrInfo as first parameter of Listen and also docs..
#2 Updated by Jan Dolinár almost 12 years ago
- Status changed from Ready for QA to Approved
- % Done changed from 50 to 100
Thanks for including and improving the patches. Works fine, just one little detail - I believe the line 191 in Skylark/App.cpp shouldn't be there:
addrinfo *addr = ipinfo.GetResult();