home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / unix / ultrix / 6814 < prev    next >
Encoding:
Text File  |  1992-09-10  |  1.1 KB  |  30 lines

  1. Newsgroups: comp.unix.ultrix
  2. Path: sparky!uunet!mcsun!sun4nl!eur.nl!pk
  3. From: pk@cs.few.eur.nl (Paul Kranenburg)
  4. Subject: Re: A major BSD socket bug?
  5. Message-ID: <1992Sep9.113405.22727@cs.few.eur.nl>
  6. Sender: news@cs.few.eur.nl
  7. Reply-To: pk@cs.eur.nl
  8. Organization: Erasmus University Rotterdam
  9. References: <1992Sep9.053147.411@lmpsbbs.comm.mot.com>
  10. Date: Wed, 9 Sep 1992 11:34:05 GMT
  11. Lines: 17
  12.  
  13. In <1992Sep9.053147.411@lmpsbbs.comm.mot.com> rittle@supra (Loren James Rittle) writes:
  14.  
  15. >I have reproduced this bug (be it in my code or the BSD OS) under
  16. >both ULTRIX 4.2A and SunOS 4.1.2.  As I don't read any sun groups, I didn't
  17. >know where to crosspost there.  The example below is under 20 lines of code.
  18. >If you are a BSD hacker, please take a look.
  19.  
  20. You just need to re-initialize `rcvsize' each time you call recv_from.
  21. Like so:
  22.  
  23. >#define ERROR(a) do { perror (a); exit (1); } while (0)
  24. >#define SEND(m) if (sendto (s,m,sizeof m,0,&a,sizeof a)==-1) ERROR ("sendto");
  25. >#define RECV rcv.sin_addr.S_un.S_addr = 0; m[0] = '\0'; \
  26.         rcvsize = sizeof rcv; \
  27. >        recvfrom (s, m, sizeof m, 0, &rcv, &rcvsize); \
  28. >        printf ("%d %s\n", rcv.sin_addr.S_un.S_addr, m)
  29.  
  30.