I\'m writing a TCP server that needs to know which interface each connection arrived from. I cannot use the address/subnet to deduce which interface was used, since there mi
I am adding another answer and a potential solution after looking through the source of Wireshark and iftop which seem to have indirectly similar functionality.
Looks to me that you can use libpcap to sniff on interfaces. Presuming you can identify some unique part of the TCP/IP session then you can track it down to an interface fairly simply using filters and session tracking.
No kernel modules (and it plays nice with threads)
http://www.ex-parrot.com/pdw/iftop/ Some simple source to have a peek at www.tcpdump.org/ for libpcap
I think you will be able to match VLANs using it too.
Also wireshark might be useful for debugging. Hope this helps! It's been on my brain since.