[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] patch: fixing byteorder in udp.scm
From: |
felix winkelmann |
Subject: |
Re: [Chicken-users] patch: fixing byteorder in udp.scm |
Date: |
Mon, 11 Apr 2005 07:10:24 +0200 |
Thanks a lot, Daishi!
I'll apply your patch and test it tonight (and update the egg
on the web-site accordingly).
cheers,
felix
On Apr 9, 2005 6:02 PM, Daishi Kato <address@hidden> wrote:
> At Mon, 04 Apr 2005 09:27:38 +0900,
> Daishi Kato wrote:
> >
> > At Sun, 3 Apr 2005 17:19:50 +0200,
> > Tim Lorenz wrote:
> > > Hello List,
> > >
> > > the code in the UDP-Egg aplies the byteorder transformation twice.
> > >
> > > The following simple patch should fix this, so that htons gets only
> > > used in the ##net#gethostaddr function instead of passing an already
> > > converted argument.
> > >
> > > Gruss
> > > Tim
> >
> > The patch works fine. Thanks a lot, Tim.
> >
> > There is another problem for me, that is,
> > the non-blocking recvfrom fails like the following.
> >
> > Is anything wrong with my environment?
> >
> > Daishi
> >
> > 8<------8<------8<------8<------8<------8<------8<------
> >
> > Version 1, Build 63 - linux-unix-gnu-x86
> > (c)2000-2004 Felix L. Winkelmann
> > #;> (require 'udp)
> > ; loading /usr/local/lib/chicken/udp.so ...
> > #;> (define s (udp-open-socket*))
> > #;> (udp-sendto s "localhost" 13 "\n")
> > 1
> > #;> (udp-recvfrom s 64)
> > 26
> > "Mon Apr 4 09:21:00 2005\r\n"
> > "127.0.0.1"
> > 13
> > #;> (udp-recvfrom s 64)
> > Error: call of non-procedure: #<unprintable object>
> > #;>
>
> Hi,
>
> With the further look into udp.scm,
> I found two more problems.
> The following is the patch for them.
> Using Tim's patch and this patch,
> it seems to me, there is no problem, so far.
>
> It would be great if someone could review the patch.
>
> Thanks,
> Daishi
>
> --- udp.scm.bak 2005-04-04 09:00:25.000000000 +0900
> +++ udp.scm 2005-04-10 00:50:54.000000000 +0900
> @@ -226,12 +226,12 @@
> ;;; make a sockaddr_in structure with the address set to INADDR_ANY
> ;;; and the specified port.
> (define ##net#make-in-addr-any-addr
> - (foreign-lambda* bool ((pointer saddr) (int port))
> + (foreign-lambda* bool ((pointer saddr) (unsigned-short port))
> #<<EOF
> struct sockaddr_in *addr = (struct sockaddr_in *)saddr;
> memset(addr, 0, sizeof(struct sockaddr_in));
> addr->sin_family = AF_INET;
> - addr->sin_port = port;
> + addr->sin_port = htons((short)port);
> addr->sin_addr.s_addr = INADDR_ANY;
> return(1);
> EOF
> @@ -286,6 +286,13 @@
> (restart-nonblocking name fd i/o thunk))
> (else (##net#error name errno))))))
>
> +(define (yield)
> + (##sys#call-with-current-continuation
> + (lambda (return)
> + (let ((ct ##sys#current-thread))
> + (##sys#setslot ct 1 (lambda () (return (##core#undefined))))
> + (##sys#schedule) ) ) ) )
> +
>
> ;;; io:event-dispatch : slist timeout-secs timeout-usecs -> bool
> ;;; high-level interface to ##io#select - take a list of descriptors
>
>
> _______________________________________________
> Chicken-users mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/chicken-users
>