Scott,
This works on my system (10.10.2, CHICKEN 4.8.0.6). Note the undocumented
argument to udp-open-socket… not sure what I was thinking.
If this works for you, I will document the argument and add the example to the
wiki.
(use udp6)
(define s (udp-open-socket 'inet6))
(udp-bind! s "::" 1337) ;; unspecified address; accept both ipv4 and ipv6
(let loop ()
(receive (len str host port) (udp-recvfrom s 1024)
(print "received " len " bytes from [" host "]:" port " : " str))
(loop))
(udp-close-socket s)
;; Then we can run netcats using IPv4 and IPv6:
$ nc -6 -u localhost 1337
hello
^C
$ nc -4 -u localhost 1337
hi
^C
;; And you should get the following output:
received 6 bytes from [::1]:62028 : hello
received 3 bytes from [::ffff:127.0.0.1]:61031 : hi
> On Feb 16, 2015, at 07:06, Scott McCoid <[email protected]> wrote:
>
> Hi Christian!
>
> Thanks for the quick help and netcat tip. I was able to send from my script
> and receive with netcat (for example: nc -u -6 -l 8000) without any problems.
> (sending to port 8000 in my script)
>
> I've tried doing the reverse situation, where I receive on the script side
> and send using netcat, but I haven't been able to get this to work. I don't
> have any errors, but I'm not receiving anything for some reason.
>
> I'll work on some chicken scripts that talk to each other and see if I can
> get this to work properly.
>
> Thanks again for your help!
> Scott
>
> On Mon, Feb 16, 2015 at 11:49 AM, Christian Kellermann <[email protected]
> <mailto:[email protected]>> wrote:
> Hi Scott!
>
> Scott McCnoid <[email protected] <mailto:[email protected]>> writes:
>
> > I'm reasonably new to chicken-scheme (and scheme in general), and I'm
> > having trouble with the udp6 (and likewise, socket) eggs. I'm trying to run
> > the example code, but the connection is always refused.
> >
> > *Error: (socket-receive!) cannot read from socket - Connection refused:
> > #<socket fd:4 af/inet sock/dgram>*
> >
> > I looked into the socket code and it seems that this is probably not the
> > fault of these eggs per se, but probably something I'm doing wrong. For
> > example, the *%socket-receive!* function makes a call to the <sys/socket.h>
> > *recv* function, which always returns -1. I've tried using other port
> > numbers to connect to, but this doesn't seem to make a difference.
> >
> > I'm on Mac OS *10.10.2* using chicken scheme v.* 4.9.0.1 *(stability/4.9.0)
> > (rev 8b3189b)
> >
> > I'm happy to help track this down if it's a bug, just let me know.
>
> The most likely reason is that on Mac OS X there is noone listening on
> port 13.
>
> You can check that manually with "nc localhost 13".
>
> The next problem is that noone is actually listening on ipv6 for that
> port. I ran into this when trying to simulate the datetime service with:
>
> "date | sudo nc -u -l -p 13"
>
> Connecting with v4 works, with v6 it doesn't.
>
> My suggestion is to test this with a known open service on your system
> or by creating a server explicitly bound to a v6 address.
>
> Please don't hesitate to report further issues and troubles!
>
> Kind regards,
>
> Christian
>
> --
> May you be peaceful, may you live in safety, may you be free from
> suffering, and may you live with ease.
>
>
> _______________________________________________
> Chicken-users mailing list
> [email protected] <mailto:[email protected]>
> https://lists.nongnu.org/mailman/listinfo/chicken-users
> <https://lists.nongnu.org/mailman/listinfo/chicken-users>
>
> _______________________________________________
> Chicken-users mailing list
> [email protected]
> https://lists.nongnu.org/mailman/listinfo/chicken-users
_______________________________________________
Chicken-users mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/chicken-users