My original UDP socket is bound to 127.0.0.1:9898.
The first time I get notification of incoming data using epoll / kqueue, I do recvfrom () and I populate a struct sockaddr called peer_name that contains peer information (ip: port).
Then I create a new UPD socket using socket (),
then I bind () this newly created socket to the same ip: port (127.0.0.1:9898) as my original socket.
then I will connect my newly created socket using connect () to the peer that just sent me something. I have information in a sockaddr structure called peer_name .
Then I add my new socket to my epoll / kqueue vector and wait for notification.
I would expect ONLY to receive a UDP frame from the peer to which I am connected "".
1 / does netstat -a -p udp Suppose to show me IP: Peer PORT, is my new socket connected to ""?
2 / I'm probably doing something wrong, because after creating my new socket this socket accepts all incoming UDP packets destined for IP: PORT I am bound to an independent source IP address: PORT.
I would like to see a working example of what I'm trying to do :) or any hint of what I'm doing wrong.
thanks!
source share