how to check port binding in pcap receiving program?

hi,

I am writing one packet receiving program using libpcap library.

Now, I want to check port is already using or not.

how to check in receiver program..

If normal program, bind return value we can able to check the port using or not.

but, in pcap program how can i check?

thank you.

Pcap is a library to capture traffic coming in on a device for any port, not just a single one. It will even capture traffic to a TCP/UDP port that's not even open. This means that it won't bind to any single port, but will watch the traffic at a very low level. If you want to transfer data between two machines, use the OS networking routines (socket/bind/connect/...) instead of Pcap.