c# - multicasting Socket.RecieveFrom: can port be 0 -


good day all

while going through msdn multicasting page, in "listener" part, in code, new endpoint create using ipaddress.any, port=0.

the ipaddress.any understandable, port 0 confuses me. should not listening on mcastport?

ipendpoint groupep = new ipendpoint(mcastaddress, mcastport); endpoint remoteep = (endpoint) new ipendpoint(ipaddress.any,0);   <======this line  try  {           while (!done)      {         console.writeline("waiting multicast packets.......");         console.writeline("enter ^c terminate.");          mcastsocket.receivefrom(bytes, ref remoteep);          console.writeline("received broadcast {0} :\n {1}\n", groupep.tostring(), encoding.ascii.getstring(bytes,0,bytes.length));         }         mcastsocket.close(); } 

read documentation carefully. initial value give in way, allow function call receivefrom grab packets coming in ipv4 remote ip addresses , ports.

if specify dedicate ip address or port, other packets won't received following call.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -