[rosedu-general] Fwd: [Asistent] netcat & connect on UDP

Lucian Adrian Grijincu lucian.grijincu at gmail.com
Sat Mar 28 01:04:35 EET 2009


FWD aici.
Presupun că sunt mai mulți willing to help pe lista asta.


---------- Forwarded message ----------
From: Alexandru Moșoi <brtzsnr at gmail.com>
Date: Sat, Mar 28, 2009 at 12:56 AM
Subject: [Asistent] netcat & connect on UDP
To: Asistent at CS Mailing List <asistent at cursuri.cs.pub.ro>


debugum cu adriana problema cu netcatul si am gasit minunatia asta
prin surse (am scos liniile mai importante):


   nnetfd = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP);
 rr = setsockopt (nnetfd, SOL_SOCKET, SO_REUSEADDR, &x, sizeof (x));
     rr = bind (nnetfd, (SA *)lclend, sizeof (SA));

    rr = recvfrom     /* and here we block... */
   (nnetfd, bigbuf_net, BIGSIZ, MSG_PEEK, (SA *) remend, &x);

/* I'm not completely clear on how this works -- BSD seems to make UDP
 just magically work in a connect()ed context, but we'll undoubtedly run
 into systems this deal doesn't work on.  For now, we apparently have to
 issue a connect() on our just-tickled socket so we can write() back.
 Again, why the fuck doesn't it just get filled in and taken care of?!
 This hack is anything but optimal.  Basically, if you want your listener
 to also be able to send data back, you need this connect() line, which
 also has the side effect that now anything from a different source or even a
 different port on the other end won't show up and will cause ICMP errors.
 I guess that's what they meant by "connect".
 Let's try to remember what the "U" is really for, eh? */

  rr = connect (nnetfd, (SA *)remend, sizeof (SA));


aparent... cu netcat nu poti sa asculti pe udp mai mult de o
"conexiune" :). fiindca dupa ce clientul moare, netcat asteapta in
continuare date pe acelasi port.

$ strace netcat -lu -p 6000

Intrebarea mea e: unde gasesc un listener de UDP care merge (cel putin
pentru linux)?

[0] https://launchpad.net/ubuntu/jaunty/+source/netcat/1.10-38

--
Alexandru Moșoi
http://alexandru.mosoi.googlepages.com

Please avoid sending me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html
_______________________________________________
asistent mailing list
asistent at cursuri.cs.pub.ro
http://cursuri.cs.pub.ro/cgi-bin/mailman/listinfo/asistent



-- 
 .
..: Lucian


More information about the rosedu-general mailing list