c - Will a disconnected udp socket still receive traffic from a port that another socket is connected to? -


i'm trying write server/client pair run on udp, , way i've been able going having server aware of client's ip , port before connection starts. new design involves waiting packet come in, recording sender address, forking child process (the parent loops around , continues listening), connect's client transmitted packet. child should receive packets associated client, documentation unclear parent socket continue receive traffic client. i'm working on program try it, figured ask question @ same time.

edit: seems when child's socket connected'd connect parent's socket too.

udp protocol not operate connections, it's connection-less protocol. enough 1 side listen , other side send datagrams data channel work.

on question (sorry, didn't got point before): forking not way out when working udp. connection-based protocols used technique. possible because:

  • you can fork right after listen()
  • the first process accepts connection works (and process posesses newly created connected socket.

when work udp don't have such gap (as before accept() tcp) know when fork (especially when have intensive datagram flow).

so, when design udp service, need either

  • use non-blocking i/o event loop or
  • design threaded solution.

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -