From 69d604c0be3546f1f79687eff598f7b021a9b573 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Fri, 18 Jul 2008 21:33:11 +0000 Subject: [PATCH] fix udp test and update docs related to socket re-binding svn: r10835 --- collects/scribblings/reference/networking.scrbl | 11 ++++++++--- collects/tests/mzscheme/udp.ss | 10 +++++++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/collects/scribblings/reference/networking.scrbl b/collects/scribblings/reference/networking.scrbl index 562c9127f8..05377e9953 100644 --- a/collects/scribblings/reference/networking.scrbl +++ b/collects/scribblings/reference/networking.scrbl @@ -304,9 +304,14 @@ and port. If a socket is not bound before it is used with a sending procedure @scheme[udp-send], @scheme[udp-send-to], etc., the sending procedure binds the socket to a random local port. Similarly, if an event from @scheme[udp-send-evt] or @scheme[udp-send-to-evt] is chosen -for a synchronization (see @secref["sync"]), the socket is bound; -if the event is not chosen, the socket may or may not become -bound. The binding of a bound socket cannot be changed. +for a synchronization (see @secref["sync"]), the socket is bound; if +the event is not chosen, the socket may or may not become bound. + +The binding of a bound socket cannot be changed, with one exception: +on some systems, if the socket is bound automatically when sending, if +the socket is disconnected via @scheme[udp-connect!], and if the +socket is later used again in a send, then the later send may change +the socket's automatic binding. If @scheme[udp-socket] is already bound or closed, the @exnraise[exn:fail:network].} diff --git a/collects/tests/mzscheme/udp.ss b/collects/tests/mzscheme/udp.ss index 18207b4d22..6fddc523b6 100644 --- a/collects/tests/mzscheme/udp.ss +++ b/collects/tests/mzscheme/udp.ss @@ -100,7 +100,15 @@ (sleep 0.05) (test udp2-r sync udp2-r) (test udp2-r sync udp2-r) -(test (list 10 "127.0.0.1" udp1-port) sync (udp-receive!-evt udp2 us1)) +(test (list 10 "127.0.0.1") + ;; Above disconnect may change udp1's auto-assigned port, + ;; so don't check the port number: + (lambda (l) + (if (and (list? l) + (= 3 (length l))) + (list (car l) (cadr l)) + l)) + (sync (udp-receive!-evt udp2 us1))) (test #f sync/timeout 0.05 udp2-r) (test #f sync/timeout 0.05 (udp-receive!-evt udp2 us1))