Feature #482

TcpSocket should be able to listen on specific IP

Added by Jan Dolinár about 9 years ago. Updated about 9 years ago.

Status:ApprovedStart date:05/30/2013
Priority:NormalDue date:
Assignee:Jan Dolinár% Done:


Category:CoreSpent time:-
Target version:-


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 ( 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.

socket.patch Magnifier - Patch to TcpSocket::Listen (1.58 KB) Jan Dolinár, 05/30/2013 09:18 PM

skylark.patch Magnifier - Using the functionality in Skylark (1.85 KB) Jan Dolinár, 05/30/2013 09:18 PM


#1 Updated by Miroslav Fidler about 9 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 about 9 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();

Also available in: Atom PDF