On Fri, Jun 29, 2012 at 12:00:28AM -0300, Christiano F. Haesbaert wrote: > On Thu, Jun 28, 2012 at 11:44:36PM -0300, Christiano F. Haesbaert wrote: > > Although the idea for using -k with -u is a good one, I don't think > > it's necessary, I for one think we should change semantics as the > > first mail suggested. > > > > The only real for using connected UDP sockets is to get the ICMP async > > errors at the socket level, ICMP port unreachable mainly. > > > > I see no reason why not to change the semantics to *not* use connected > > UDP sockets, since the server will *never* write anything back to the > > client.
Maybe some expect the server to be able to write back, just like it would with TCP. A flag (not nessesarily the -k) seems cleaner. > > But then we would have to drop print "connection received from...", > which is being introduced in another diff. Now I'm more inclined in > going for the -k, that way we know when to supress the message. > > > > > > > On Mon, Jun 25, 2012 at 01:41:48PM +0300, Lazaros Koromilas wrote: > > > On Sun, Jun 24, 2012 at 11:23:05PM +0200, Ariane van der Steldt wrote: > > > > On Mon, Jun 25, 2012 at 12:09:33AM +0300, dsp wrote: > > > > > We observe the following behaviour when running nc -ul. > > > > > The server begins on a recvfrom() and when data arrives it > > > > > connects() the socket. > > > > > When the client dies , the server remains in a connected state > > > > > therefore ignoring subsequent data arriving on the port. > > > > > Is this really the intended logic for a connectionless protocol like > > > > > UDP? We proceeded to comment out the connect statement and we were > > > > > able to receive data from multiple *sessions* as expected. > > > > > Can you shed some light on the matter??? > > > > > > > > Reading the man page, I think you want to add the -k option to nc. > > > > > > The -k option does nothing when used with -u because the readwrite() > > > session cannot end. Would the following be a reasonable change? > > > It has the side effect of letting UDP packets to interleave. > > > > > > > > > Index: nc.1 > > > =================================================================== > > > RCS file: /cvs/src/usr.bin/nc/nc.1,v > > > retrieving revision 1.60 > > > diff -u -p -r1.60 nc.1 > > > --- nc.1 7 Feb 2012 12:11:43 -0000 1.60 > > > +++ nc.1 25 Jun 2012 10:40:15 -0000 > > > @@ -119,6 +119,10 @@ is completed. > > > It is an error to use this option without the > > > .Fl l > > > option. > > > +When used together with the > > > +.Fl u > > > +option all UDP datagrams arriving on the port are received; > > > +not just those sent by the first client to connect. > > > .It Fl l > > > Used to specify that > > > .Nm > > > Index: netcat.c > > > =================================================================== > > > RCS file: /cvs/src/usr.bin/nc/netcat.c,v > > > retrieving revision 1.105 > > > diff -u -p -r1.105 netcat.c > > > --- netcat.c 9 Feb 2012 06:25:35 -0000 1.105 > > > +++ netcat.c 25 Jun 2012 10:40:15 -0000 > > > @@ -364,9 +364,12 @@ main(int argc, char *argv[]) > > > if (rv < 0) > > > err(1, "recvfrom"); > > > > > > - rv = connect(s, (struct sockaddr *)&z, len); > > > - if (rv < 0) > > > - err(1, "connect"); > > > + if (!kflag) { > > > + rv = connect(s, (struct sockaddr *)&z, > > > + len); > > > + if (rv < 0) > > > + err(1, "connect"); > > > + } > > > > > > readwrite(s); > > > } else {