Browse Source
New 'make.tcl vfslibs' step (also run inside 'make.tcl project' before kit vfs assembly): propagates declared vendored platform-library packages into kit vfs lib_tcl<N> trees, ending the hand-copying that let kits ship a known-buggy tcludp through three make invocations (the G-036/G-037 motivating case). - declaration: src/runtime/vendorlib_vfs.toml, parsed with bootsupport tomlish (no ad-hoc parsing; G-024's mapvfs toml conversion NOT required first - this file is recorded as a candidate for absorption into it). [install.<name>] entries: source (relative to src/), targets (kit vfs lib folders relative to src/vfs/), optional supersedes (folder names removed from each target before install - explicit, no silent mixed-version provision per G-035 concerns). - participation is per-package per-kit; authority is the declaration - nothing syncs undeclared, so the known vendorlib/kit twapi drift is deliberately untouched (resolves the direction/authority design question). - punkcheck provenance at src/vfs/.punkcheck (gitignored, outside kit payloads); skip-if-unchanged proven (rerun: 0 copied, 9 skipped per target); malformed/unresolvable entries fail the build naming the entry (exit 3). - 8.6 kits upgraded (the G-036 loose-end decision, recorded): tcludp 1.0.13 is dual-generation (pkgIndex selects tcl9udp1013.dll on 9+, udp1013t.dll on 8.5+) so the single vendorlib_tcl9 source serves punk8win.vfs/lib_tcl8; superseded udp1.0.12 removed. - verified on rebuilt kits: punksys/punkbi (8.6.13) and punk902z (9.0.2) all report package require udp == 1.0.13 loading the generation-appropriate dll from their vfs; no udp1.0.12 remains under src/vfs; punksys piped-shell exit smoke clean. - G-037 flipped proposed -> achieved 2026-07-08 under user direction (no intermediate active stop). - includes project-build byproducts via established channels: bootsupport snapshots refreshed to punk-0.2.1 / punk::lib-0.3.0 (from today's version bumps) and make.tcl synced into layout copies. - project 0.4.8 (CHANGELOG entry) Assisted-by: harness=claude; primary-model=claude-fable-5; api-location=anthropic.commaster
27 changed files with 1325 additions and 43 deletions
@ -1,3 +1,3 @@
|
||||
[project] |
||||
name = "punkshell" |
||||
version = "0.4.7" |
||||
version = "0.4.8" |
||||
|
||||
@ -0,0 +1,32 @@
|
||||
# vendorlib -> kit vfs platform-library propagation (goal G-037) |
||||
# |
||||
# Declares which vendored platform-library package folders (paths relative to src/) are |
||||
# installed into which kit vfs lib trees (paths relative to src/vfs/). Processed by |
||||
# 'tclsh src/make.tcl vfslibs' - and automatically as part of 'tclsh src/make.tcl project' - |
||||
# with punkcheck-tracked provenance (records in src/vfs/.punkcheck, outside kit payloads). |
||||
# |
||||
# Participation is per-package per-kit by design: kit vfs package sets intentionally differ |
||||
# (e.g. twapi versions vary per kit), so nothing is blanket-copied and a vendorlib drop does |
||||
# not force a package into every kit. |
||||
# |
||||
# Cross-generation installs are allowed when the package supports both Tcl major versions |
||||
# (e.g. tcludp 1.0.13 ships tcl9udp1013.dll + udp1013t.dll with a pkgIndex.tcl that selects |
||||
# by generation - so the same source folder serves lib_tcl9 and lib_tcl8 targets). |
||||
# |
||||
# Keys per [install.<name>] entry: |
||||
# source - package folder path relative to src/ |
||||
# targets - list of kit vfs lib folders relative to src/vfs/ |
||||
# supersedes - optional list of legacy/older package folder names to remove from each |
||||
# target before install (explicit - no silent mixed-version provision, per |
||||
# the G-035 concerns) |
||||
# |
||||
# This file is a candidate for absorption into the mapvfs toml conversion (goal G-024). |
||||
|
||||
[install.tcludp] |
||||
source = "vendorlib_tcl9/win32-x86_64/tcludp1.0.13" |
||||
targets = [ |
||||
"punk9win.vfs/lib_tcl9", |
||||
"punk9win_for_tkruntime.vfs/lib_tcl9", |
||||
"punk8win.vfs/lib_tcl8", |
||||
] |
||||
supersedes = ["udp1.0.12", "tcludp1.0.12"] |
||||
@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env tclsh |
||||
# multicast.tcl - Copyright (C) 2004 Pat Thoyts <patthoyts@users.sf.net> |
||||
# |
||||
# Demonstrate the use of broadcast UDP sockets. |
||||
# |
||||
# You can send to ths using netcat: |
||||
# echo HELLO | nc -u 192.168.255.255 7772 |
||||
# |
||||
# $Id: broadcast.tcl,v 1.1 2004/11/22 23:48:47 patthoyts Exp $ |
||||
|
||||
package require udp 1.0.6 |
||||
|
||||
proc udpEvent {chan} { |
||||
set data [read $chan] |
||||
set peer [fconfigure $chan -peer] |
||||
puts "$peer [string length $data] '$data'" |
||||
if {[string match "QUIT*" $data]} { |
||||
close $chan |
||||
set ::forever 1 |
||||
} |
||||
return |
||||
} |
||||
|
||||
# Select a subnet and the port number. |
||||
set subnet 192.168.255.255 |
||||
set port 7772 |
||||
|
||||
# Create a listening socket and configure for sending too. |
||||
set s [udp_open $port] |
||||
fconfigure $s -buffering none -blocking 0 |
||||
fconfigure $s -broadcast 1 -remote [list $subnet $port] |
||||
fileevent $s readable [list udpEvent $s] |
||||
|
||||
# Announce our presence and run |
||||
puts -nonewline $s "hello, world" |
||||
set forever 0 |
||||
vwait ::forever |
||||
|
||||
exit |
||||
@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env tclsh |
||||
# bug1158628.tcl - Copyright (C) 2005 Pat Thoyts <patthoyts@users.sf.net> |
||||
# |
||||
# "On windows XP, I have a GUI that has an exit buttons which when |
||||
# pressed does: {set done 1; destroy .;exit} If there is an open UDP |
||||
# channel with a fileevent on it, the program will not exit -- |
||||
# i.e. task manager still shows it. Also if I have the console up, the |
||||
# console goes away when the exit button is invoked, but the program |
||||
# does not exit. NOTE -- all windows are correctly destroyed (or at |
||||
# least withdrawn)" |
||||
# |
||||
# The fault is calling Tcl_UnregisterChannel in the udpClose function. |
||||
# We must let tcl handle this itself. Solved by Reinhard Max. |
||||
# |
||||
# This script demonstrates the problem. Using udp 1.0.6 the program hangs |
||||
# after printing "Exiting...". With the fix applied it properly exits. |
||||
# |
||||
# $Id: bug1158628.tcl,v 1.2 2005/05/19 20:46:23 patthoyts Exp $ |
||||
|
||||
#load [file join [file dirname [info script]] .. win Release udp107.dll] |
||||
#load [file join [file dirname [info script]] .. i386-unknown-openbsd3.6 libudp107.so] |
||||
package require udp |
||||
|
||||
variable forever 0 |
||||
|
||||
proc Event {sock} { |
||||
variable forever |
||||
set pkt [read $sock] |
||||
set peer [fconfigure $sock -peer] |
||||
puts "Recieved [string length $pkt] from $peer\n$pkt" |
||||
#set forever 1 |
||||
return |
||||
} |
||||
|
||||
proc Listen {port} { |
||||
set s [udp_open $port] |
||||
fconfigure $s -blocking 0 -buffering none -translation binary |
||||
fileevent $s readable [list Event $s] |
||||
return $s |
||||
} |
||||
|
||||
proc Exit {sock} { |
||||
puts "Exiting" |
||||
exit 0 |
||||
} |
||||
|
||||
if {!$tcl_interactive} { |
||||
puts "Bug #1158628 - hangs in exit if open udp channels" |
||||
puts " Using a buggy version, this will hang after printing Exiting..." |
||||
puts "" |
||||
set sock [Listen 10245] |
||||
puts "Wait 1 sec..." |
||||
after 1000 [list Exit $sock] |
||||
vwait forever |
||||
close $sock |
||||
} |
||||
@ -0,0 +1,81 @@
|
||||
#!/usr/bin/env tclsh |
||||
# chat.tcl - Copyright (C) 2004 Pat Thoyts <patthoyts@users.sourceforge.net> |
||||
# |
||||
# This is a sample application from TclUDP. |
||||
# |
||||
# This illustrates the use of multicast UDP messages to implement a |
||||
# primitive chat application. |
||||
# |
||||
# $Id: chat.tcl,v 1.2 2007/04/10 23:36:14 patthoyts Exp $ |
||||
|
||||
package require Tk 8.4- |
||||
package require udp 1.0.6 |
||||
|
||||
variable Address 224.5.1.21 |
||||
variable Port 7771 |
||||
|
||||
proc Receive {sock} { |
||||
set pkt [read $sock] |
||||
set peer [fconfigure $sock -peer] |
||||
AddMessage $peer $pkt |
||||
return |
||||
} |
||||
|
||||
proc Start {addr port} { |
||||
set s [udp_open $port] |
||||
fconfigure $s -blocking 0 -buffering none -translation binary \ |
||||
-mcastadd $addr -remote [list $addr $port] |
||||
fileevent $s readable [list ::Receive $s] |
||||
return $s |
||||
} |
||||
|
||||
proc CreateGui {socket} { |
||||
text .t -yscrollcommand {.s set} |
||||
scrollbar .s -command {.t yview} |
||||
frame .f -border 0 |
||||
entry .f.e -textvariable ::_msg |
||||
button .f.ok -text Send -underline 0 \ |
||||
-command "SendMessage $socket \$::_msg" |
||||
button .f.ex -text Exit -underline 1 -command {destroy .} |
||||
pack .f.ex .f.ok -side right |
||||
pack .f.e -side left -expand 1 -fill x |
||||
grid .t .s -sticky news |
||||
grid .f - -sticky ew |
||||
grid columnconfigure . 0 -weight 1 |
||||
grid rowconfigure . 0 -weight 1 |
||||
bind .f.e <Return> {.f.ok invoke} |
||||
.t tag configure CLNT -foreground red |
||||
.t configure -tabs {90} |
||||
} |
||||
|
||||
proc SendMessage {sock msg} { |
||||
puts -nonewline $sock $msg |
||||
} |
||||
|
||||
proc AddMessage {client msg} { |
||||
set msg [string map [list "\r\n" "" "\r" "" "\n" ""] $msg] |
||||
set client [lindex $client 0] |
||||
if {[string length $msg] > 0} { |
||||
.t insert end "$client\t" CLNT "$msg\n" MSG |
||||
.t see end |
||||
} |
||||
} |
||||
|
||||
proc Main {} { |
||||
variable Address |
||||
variable Port |
||||
variable sock |
||||
set sock [Start $Address $Port] |
||||
CreateGui $sock |
||||
after idle [list SendMessage $sock \ |
||||
"$::tcl_platform(user)@[info hostname] connected"] |
||||
tkwait window . |
||||
close $sock |
||||
} |
||||
|
||||
if {!$tcl_interactive} { |
||||
set r [catch [linsert $argv 0 Main] err] |
||||
if {$r} {puts $::errorInfo} else {puts $err} |
||||
exit 0 |
||||
} |
||||
|
||||
@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env tclsh |
||||
# multicast.tcl - Copyright (C) 2004 Pat Thoyts <patthoyts@users.sf.net> |
||||
# |
||||
# Demonstrate the use of IPv4 multicast UDP sockets. |
||||
# |
||||
# You can send to ths using netcat: |
||||
# echo HELLO | nc -u 224.5.1.21 7771 |
||||
# |
||||
# $Id: multicast.tcl,v 1.3 2007/04/10 23:49:38 patthoyts Exp $ |
||||
|
||||
package require udp 1.0.6 |
||||
|
||||
proc udpEvent {chan} { |
||||
set data [read $chan] |
||||
set peer [fconfigure $chan -peer] |
||||
set group [lindex [fconfigure $chan -remote] 0] |
||||
puts "$peer ($group) [string length $data] '$data' {[fconfigure $chan]}" |
||||
if {[string match "QUIT*" $data]} { |
||||
close $chan |
||||
set ::forever 1 |
||||
} |
||||
return |
||||
} |
||||
|
||||
# Select a multicast group and the port number. |
||||
# |
||||
# We have two groups here to show that it's possible. |
||||
# |
||||
set group1 224.5.1.21 |
||||
set group2 224.5.2.21 |
||||
set port 7771 |
||||
|
||||
# Create a listening socket and configure for sending too. |
||||
set s [udp_open $port] |
||||
fconfigure $s -buffering none -blocking 0 |
||||
fconfigure $s -mcastadd $group2 -remote [list $group2 $port] |
||||
fconfigure $s -mcastadd $group1 -remote [list $group1 $port] |
||||
fileevent $s readable [list udpEvent $s] |
||||
|
||||
# Announce our presence and run |
||||
puts -nonewline $s "hello, world" |
||||
set forever 0 |
||||
vwait ::forever |
||||
|
||||
exit |
||||
@ -0,0 +1,65 @@
|
||||
#!/usr/bin/env tclsh |
||||
# udpsend.tcl - Copyright (C) 2004 Pat Thoyts <patthoyts@users.sf.net> |
||||
# |
||||
# Demo application - cat data from stdin via a UDP socket. |
||||
# |
||||
# $Id: udpcat.tcl,v 1.1 2004/11/22 23:48:47 patthoyts Exp $ |
||||
|
||||
package require udp 1.0.6 |
||||
|
||||
proc Event {sock} { |
||||
global forever |
||||
set pkt [read $sock] |
||||
set peer [fconfigure $sock -peer] |
||||
puts "Received [string length $pkt] from $peer\n$pkt" |
||||
set forever 1 |
||||
return |
||||
} |
||||
|
||||
proc Send {host port {msg {}}} { |
||||
set s [udp_open] |
||||
fconfigure $s -blocking 0 -buffering none -translation binary \ |
||||
-remote [list $host $port] |
||||
fileevent $s readable [list Event $s] |
||||
if {$msg eq {}} { |
||||
fcopy stdin $s |
||||
} else { |
||||
puts -nonewline $s $msg |
||||
} |
||||
|
||||
after 2000 |
||||
close $s |
||||
} |
||||
|
||||
proc Listen {port} { |
||||
set s [udp_open $port] |
||||
fconfigure $s -blocking 0 -buffering none -translation binary |
||||
fileevent $s readable [list Event $s] |
||||
return $s |
||||
} |
||||
|
||||
# ------------------------------------------------------------------------- |
||||
# Runtime |
||||
# udpsend listen -port N -blocking 0 |
||||
# udpsend send host port message |
||||
# ------------------------------------------------------------------------- |
||||
set forever 0 |
||||
|
||||
if {! $tcl_interactive} { |
||||
switch -exact -- [set cmd [lindex $argv 0]] { |
||||
send { |
||||
eval [list Send] [lrange $argv 1 end] |
||||
} |
||||
listen { |
||||
set s [Listen [lindex $argv 1]] |
||||
vwait ::forever |
||||
close $s |
||||
} |
||||
default { |
||||
puts "usage: udpcat send host port ?message?\ |
||||
\n udpcat listen port" |
||||
} |
||||
} |
||||
} |
||||
|
||||
|
||||
@ -0,0 +1,33 @@
|
||||
# -*- tcl -*- |
||||
# Tcl package index file, version 1.1 |
||||
# |
||||
if {[package vsatisfies [package provide Tcl] 9.0-]} { |
||||
package ifneeded udp 1.0.13 [list apply {{dir} { |
||||
# Load library |
||||
load [file join $dir tcl9udp1013.dll] [string totitle udp] |
||||
|
||||
# Source init file |
||||
set initScript [file join $dir udp.tcl] |
||||
if {[file exists $initScript]} { |
||||
source -encoding utf-8 $initScript |
||||
} |
||||
}} $dir] |
||||
} else { |
||||
if {![package vsatisfies [package provide Tcl] 8.5]} {return} |
||||
package ifneeded udp 1.0.13 [list apply {{dir} { |
||||
# Load library |
||||
if {[string tolower [file extension udp1013t.dll]] in [list .dll .dylib .so]} { |
||||
# Load dynamic library |
||||
load [file join $dir udp1013t.dll] [string totitle udp] |
||||
} else { |
||||
# Static library |
||||
load {} [string totitle udp] |
||||
} |
||||
|
||||
# Source init file |
||||
set initScript [file join $dir udp.tcl] |
||||
if {[file exists $initScript]} { |
||||
source -encoding utf-8 $initScript |
||||
} |
||||
}} $dir] |
||||
} |
||||
Binary file not shown.
@ -0,0 +1,326 @@
|
||||
<!DOCTYPE html><html><head> |
||||
<meta charset="UTF-8"> |
||||
<meta name="viewport" content="width=device-width, initial-scale=1"> |
||||
<title>udp - Tcl UDP extension</title> |
||||
<style type="text/css"><!-- |
||||
HTML { |
||||
background: #FFFFFF; |
||||
color: black; |
||||
} |
||||
BODY { |
||||
background: #FFFFFF; |
||||
color: black; |
||||
} |
||||
DIV.doctools { |
||||
margin-left: 10%; |
||||
margin-right: 10%; |
||||
} |
||||
DIV.doctools H1,DIV.doctools H2 { |
||||
margin-left: -5%; |
||||
} |
||||
H1, H2, H3, H4 { |
||||
margin-top: 1em; |
||||
font-family: sans-serif; |
||||
font-size: large; |
||||
color: #005A9C; |
||||
background: transparent; |
||||
text-align: left; |
||||
} |
||||
H1.doctools_title { |
||||
text-align: center; |
||||
} |
||||
UL,OL { |
||||
margin-right: 0em; |
||||
margin-top: 3pt; |
||||
margin-bottom: 3pt; |
||||
} |
||||
UL LI { |
||||
list-style: disc; |
||||
} |
||||
OL LI { |
||||
list-style: decimal; |
||||
} |
||||
DT { |
||||
padding-top: 1ex; |
||||
} |
||||
UL.doctools_toc,UL.doctools_toc UL, UL.doctools_toc UL UL { |
||||
font: normal 12pt/14pt sans-serif; |
||||
list-style: none; |
||||
} |
||||
LI.doctools_section, LI.doctools_subsection { |
||||
list-style: none; |
||||
margin-left: 0em; |
||||
text-indent: 0em; |
||||
padding: 0em; |
||||
} |
||||
PRE { |
||||
display: block; |
||||
font-family: monospace; |
||||
white-space: pre; |
||||
margin: 0%; |
||||
padding-top: 0.5ex; |
||||
padding-bottom: 0.5ex; |
||||
padding-left: 1ex; |
||||
padding-right: 1ex; |
||||
width: 100%; |
||||
} |
||||
PRE.doctools_example { |
||||
color: black; |
||||
background: #f5dcb3; |
||||
border: 1px solid black; |
||||
} |
||||
UL.doctools_requirements LI, UL.doctools_syntax LI { |
||||
list-style: none; |
||||
margin-left: 0em; |
||||
text-indent: 0em; |
||||
padding: 0em; |
||||
} |
||||
DIV.doctools_synopsis { |
||||
color: black; |
||||
background: #80ffff; |
||||
border: 1px solid black; |
||||
font-family: serif; |
||||
margin-top: 1em; |
||||
margin-bottom: 1em; |
||||
} |
||||
UL.doctools_syntax { |
||||
margin-top: 1em; |
||||
border-top: 1px solid black; |
||||
} |
||||
UL.doctools_requirements { |
||||
margin-bottom: 1em; |
||||
border-bottom: 1px solid black; |
||||
} |
||||
--></style> |
||||
</head> |
||||
<!-- Generated from file 'udp.man' by tcllib/doctools with format 'html' |
||||
--> |
||||
<!-- Copyright &copy; 1999-2000 Columbia University; all rights reserved |
||||
--> |
||||
<!-- udp.n |
||||
--> |
||||
<body><div class="doctools"> |
||||
<h1 class="doctools_title">udp(n) 1.0.13 udp "Tcl UDP extension"</h1> |
||||
<div id="name" class="doctools_section"><h2><a name="name">Name</a></h2> |
||||
<p>udp - Create UDP sockets in Tcl</p> |
||||
</div> |
||||
<div id="toc" class="doctools_section"><h2><a name="toc">Table Of Contents</a></h2> |
||||
<ul class="doctools_toc"> |
||||
<li class="doctools_section"><a href="#toc">Table Of Contents</a></li> |
||||
<li class="doctools_section"><a href="#synopsis">Synopsis</a></li> |
||||
<li class="doctools_section"><a href="#section1">Description</a></li> |
||||
<li class="doctools_section"><a href="#section2">COMMANDS</a></li> |
||||
<li class="doctools_section"><a href="#section3">EXAMPLES</a></li> |
||||
<li class="doctools_section"><a href="#section4">HISTORY</a></li> |
||||
<li class="doctools_section"><a href="#see-also">See Also</a></li> |
||||
<li class="doctools_section"><a href="#keywords">Keywords</a></li> |
||||
<li class="doctools_section"><a href="#copyright">Copyright</a></li> |
||||
</ul> |
||||
</div> |
||||
<div id="synopsis" class="doctools_section"><h2><a name="synopsis">Synopsis</a></h2> |
||||
<div class="doctools_synopsis"> |
||||
<ul class="doctools_requirements"> |
||||
<li>package require <b class="pkgname">Tcl 8.5-</b></li> |
||||
<li>package require <b class="pkgname">udp 1.0.13</b></li> |
||||
</ul> |
||||
<ul class="doctools_syntax"> |
||||
<li><a href="#1"><b class="cmd">udp_open</b> <span class="opt">?<i class="arg">localport</i>?</span> <span class="opt">?<b class="option">reuse</b>?</span> <span class="opt">?<b class="option">ipv6</b>?</span></a></li> |
||||
<li><a href="#2"><b class="cmd">udp_conf</b> <i class="arg">channel</i> <i class="arg">host</i> <i class="arg">port</i></a></li> |
||||
<li><a href="#3"><b class="cmd">udp_conf</b> <i class="arg">channel</i> <i class="arg"><span class="opt">?optionName?</span></i> <i class="arg"><span class="opt">?value?</span></i> <i class="arg"><span class="opt">?optionName value ...?</span></i></a></li> |
||||
<li><a href="#4"><b class="cmd">udp_peek</b> <i class="arg">channel</i> <span class="opt">?<i class="arg">buffersize</i>?</span></a></li> |
||||
<li><a href="#5"><b class="cmd">::udp::build-info</b></a></li> |
||||
<li><a href="#6"><b class="cmd">::udp::getaddrinfo</b> <i class="arg"><b class="option">-hostname</b> name</i> <i class="arg"><span class="opt">?optionName value ...?</span></i></a></li> |
||||
<li><a href="#7"><b class="cmd">::udp::getnameinfo</b> <i class="arg">address</i> <b class="option"><span class="opt">?ipv6?</span></b></a></li> |
||||
</ul> |
||||
</div> |
||||
</div> |
||||
<div id="section1" class="doctools_section"><h2><a name="section1">Description</a></h2> |
||||
<p>This package provides support for using UDP through Tcl. The package provides |
||||
a new channel type and attempts to permit the use of packet oriented UDP |
||||
over stream oriented Tcl channels. The package defined three commands but |
||||
<b class="cmd">udp_conf</b> should be considered depreciated in favor of the standard |
||||
Tcl command <b class="cmd">fconfigure</b>.</p> |
||||
</div> |
||||
<div id="section2" class="doctools_section"><h2><a name="section2">COMMANDS</a></h2> |
||||
<dl class="doctools_definitions"> |
||||
<dt><a name="1"><b class="cmd">udp_open</b> <span class="opt">?<i class="arg">localport</i>?</span> <span class="opt">?<b class="option">reuse</b>?</span> <span class="opt">?<b class="option">ipv6</b>?</span></a></dt> |
||||
<dd><p><b class="cmd">udp_open</b> will open a UDP socket. If a <i class="arg">localport</i> is specified the UDP |
||||
socket will be opened on that port. Otherwise the system will choose a port |
||||
and the user can use the <b class="cmd">udp_conf</b> command to obtain the port number |
||||
if required.</p> |
||||
<p>The following keywords can be used to specify options on the opened socket.</p> |
||||
<dl class="doctools_definitions"> |
||||
<dt><b class="option">reuse</b></dt> |
||||
<dd><p>Using this keyword sets the SO_REUSEADDR socket option which permits multiple |
||||
sockets to be bound to the same address/port combination.</p></dd> |
||||
<dt><b class="option">ipv6</b></dt> |
||||
<dd><p>By default a IPv4 socket is created. When keyword <b class="option">ipv6</b> is specified, an IPv6 |
||||
socket is opened.</p></dd> |
||||
</dl></dd> |
||||
<dt><a name="2"><b class="cmd">udp_conf</b> <i class="arg">channel</i> <i class="arg">host</i> <i class="arg">port</i></a></dt> |
||||
<dd><p><em>Deprecated</em> in favor of the standard Tcl <b class="cmd">fconfigure</b> or |
||||
<b class="cmd">chan configure</b> commands.</p> |
||||
<p><b class="cmd">udp_conf</b> in this configuration is used to specify the remote destination |
||||
for packets written to this <i class="arg">channel</i>. You must call this command before |
||||
writing data to the UDP socket.</p></dd> |
||||
<dt><a name="3"><b class="cmd">udp_conf</b> <i class="arg">channel</i> <i class="arg"><span class="opt">?optionName?</span></i> <i class="arg"><span class="opt">?value?</span></i> <i class="arg"><span class="opt">?optionName value ...?</span></i></a></dt> |
||||
<dd><p><em>Deprecated</em> in favor of the standard Tcl <b class="cmd">fconfigure</b> or |
||||
<b class="cmd">chan configure</b> commands.</p> |
||||
<p>In addition to being used to configure the remote host, the <b class="cmd">udp_conf</b> |
||||
command is used to obtain information about the UDP socket. NOTE all these |
||||
options are now available using the standard Tcl <b class="cmd">fconfigure</b> or |
||||
<b class="cmd">chan configure</b> command.</p> |
||||
<dl class="doctools_definitions"> |
||||
<dt><b class="option">-myport</b></dt> |
||||
<dd><p>Returns the local port number of the socket. Read-only option.</p></dd> |
||||
<dt><b class="option">-remote</b> <i class="arg"><span class="opt">?address port?</span></i></dt> |
||||
<dd><p>Specifies or returns the remote hostname and port number. Can also be set using |
||||
<b class="cmd">udp_conf</b> <i class="arg">channel</i> <i class="arg">host</i> <i class="arg">port</i>.</p></dd> |
||||
<dt><b class="option">-peer</b></dt> |
||||
<dd><p>Returns the remote hostname and port number for the packet most recently |
||||
received by this socket. Read-only option.</p></dd> |
||||
<dt><b class="option">-family</b></dt> |
||||
<dd><p>Returns whether socket is configured for IPv4 or IPv6. Read-only option.</p></dd> |
||||
<dt><b class="option">-broadcast</b> <i class="arg"><span class="opt">?boolean?</span></i></dt> |
||||
<dd><p>Specifies or returns whether can listen and send on the broadcast address. For some systems |
||||
a flag must be set on the socket to use broadcast. This option is not permitted when |
||||
using IPv6, instead use multicast.</p></dd> |
||||
<dt><b class="option">-ttl</b> <i class="arg"><span class="opt">?count?</span></i></dt> |
||||
<dd><p>The time-to-live is given as the number of router hops the packet may do. For |
||||
multicast packets this is important in specifying the distribution of the |
||||
packet. The system default for multicast is 1 which restricts the packet |
||||
to the local subnet. To permit packets to pass routers, you must increase the |
||||
ttl. A value of 31 should keep it within a site, while 255 is global.</p></dd> |
||||
<dt><b class="option">-mcastadd</b> groupaddr</dt> |
||||
<dd></dd> |
||||
<dt><b class="option">-mcastadd</b> "groupaddr netwif"</dt> |
||||
<dd></dd> |
||||
<dt><b class="option">-mcastdrop</b> groupaddr</dt> |
||||
<dd></dd> |
||||
<dt><b class="option">-mcastdrop</b> "groupaddr netwif"</dt> |
||||
<dd></dd> |
||||
<dt><b class="option">-mcastgroups</b></dt> |
||||
<dd><p><b class="package">tcludp</b> sockets can support IPv4 and IPv6 multicast operations. To receive |
||||
multicast packets the application has to notify the operating system that |
||||
it should join a particular multicast group. For IPv4 these are specified as addresses |
||||
in the range 224.0.0.0 to 239.255.255.255.</p> |
||||
<p>When specifying only the <i class="arg">groupaddr</i> the system will determine the network interface to use. |
||||
Specifying the <i class="arg">netwif</i> will join a multicast group on a specific network interface. |
||||
This is useful on a multihomed system with multiple network interfaces. |
||||
On windows you must specify the network interface index. For other platforms the network |
||||
interface (e.g. 'eth0') name can be specified.</p> |
||||
<p>To view the current set of multicast groups for a channel use <i class="arg">-mcastgroups</i></p></dd> |
||||
<dt><b class="option">-mcastif</b></dt> |
||||
<dd><p>Returns which interface is used for outgoing multicast packets. UNIX only.</p></dd> |
||||
<dt><b class="option">-mcastloop</b> <i class="arg"><span class="opt">?boolean?</span></i></dt> |
||||
<dd><p>With multicast udp the system can choose to receive packets that it has sent |
||||
or it can drop them. This is known as multicast loopback and can be controlled |
||||
using this option. By default the value is true and your application will receive |
||||
its own transmissions.</p></dd> |
||||
</dl></dd> |
||||
<dt><a name="4"><b class="cmd">udp_peek</b> <i class="arg">channel</i> <span class="opt">?<i class="arg">buffersize</i>?</span></a></dt> |
||||
<dd><p>Examine a packet without removing it from the buffer. Option <i class="arg">buffersize</i> specifies the |
||||
maximum buffer size. Value must be between 0 and 16.</p> |
||||
<p>This function is not available on windows.</p></dd> |
||||
<dt><a name="5"><b class="cmd">::udp::build-info</b></a></dt> |
||||
<dd><p>Return information on the build environment.</p></dd> |
||||
<dt><a name="6"><b class="cmd">::udp::getaddrinfo</b> <i class="arg"><b class="option">-hostname</b> name</i> <i class="arg"><span class="opt">?optionName value ...?</span></i></a></dt> |
||||
<dd><p>Returns a list with info on the IP address matching the specified parameters. |
||||
Valid options are:</p> |
||||
<dl class="doctools_definitions"> |
||||
<dt><b class="option">-hostname</b> <i class="arg">name</i></dt> |
||||
<dd><p>Specifies which IP address to use for lookup. Can use IP address or name. Required option.</p></dd> |
||||
<dt><b class="option">-port</b> <i class="arg">number</i></dt> |
||||
<dd><p>Specifies which port number to use for lookup.</p></dd> |
||||
<dt><b class="option">-service</b> <i class="arg">name</i></dt> |
||||
<dd><p>Specifies which well-known service (i.e. http, https, etc.) to use for port in lookup.</p></dd> |
||||
<dt><b class="option">-ipv4</b></dt> |
||||
<dd><p>Only return IP v4 addresses.</p></dd> |
||||
<dt><b class="option">-ipv6</b></dt> |
||||
<dd><p>Only return IP v6 addresses.</p></dd> |
||||
<dt><b class="option">-server</b></dt> |
||||
<dd><p>Only return services for which hostname is a server.</p></dd> |
||||
<dt><b class="option">-tcp</b></dt> |
||||
<dd><p>Only return TCP services.</p></dd> |
||||
<dt><b class="option">-udp</b></dt> |
||||
<dd><p>Only return UDP services.</p></dd> |
||||
</dl></dd> |
||||
<dt><a name="7"><b class="cmd">::udp::getnameinfo</b> <i class="arg">address</i> <b class="option"><span class="opt">?ipv6?</span></b></a></dt> |
||||
<dd><p><b class="cmd">::udp::getnameinfo</b> will return the name(s) corresponding to IP |
||||
address <i class="arg">address</i>. With <i class="arg">ipv6</i>, address is an IPv6 address.</p></dd> |
||||
</dl> |
||||
</div> |
||||
<div id="section3" class="doctools_section"><h2><a name="section3">EXAMPLES</a></h2> |
||||
<pre class="doctools_example"> |
||||
# Send data to a remote UDP socket |
||||
proc udp_puts {host port} { |
||||
set s [udp_open] |
||||
fconfigure $s -remote [list $host $port] |
||||
puts $s "Hello, World" |
||||
close $f |
||||
} |
||||
</pre> |
||||
<pre class="doctools_example"> |
||||
# A simple UDP server |
||||
package require udp |
||||
proc udpEventHandler {sock} { |
||||
set pkt [read $sock] |
||||
set peer [fconfigure $sock -peer] |
||||
puts "$peer: [string length $pkt] {$pkt}" |
||||
return |
||||
} |
||||
proc udp_listen {port} { |
||||
set srv [udp_open $port] |
||||
fconfigure $srv -buffering none -translation binary |
||||
fileevent $srv readable [list ::udpEventHandler $srv] |
||||
puts "Listening on udp port: [fconfigure $srv -myport]" |
||||
return $srv |
||||
} |
||||
set sock [udp_listen 53530] |
||||
vwait forever |
||||
close $sock |
||||
</pre> |
||||
<pre class="doctools_example"> |
||||
# A multicast demo. |
||||
proc udpEvent {chan} { |
||||
set data [read $chan] |
||||
set peer [fconfigure $chan -peer] |
||||
puts "$peer [string length $data] '$data'" |
||||
if {[string match "QUIT*" $data]} { |
||||
close $chan |
||||
set ::forever 1 |
||||
} |
||||
return |
||||
} |
||||
set group 224.5.1.21 |
||||
set port 7771 |
||||
set s [udp_open $port] |
||||
fconfigure $s -buffering none -blocking 0 |
||||
fconfigure $s -mcastadd $group -remote [list $group $port] |
||||
fileevent $s readable [list udpEvent $s] |
||||
puts -nonewline $s "hello, world" |
||||
set ::forever 0 |
||||
vwait ::forever |
||||
exit |
||||
</pre> |
||||
</div> |
||||
<div id="section4" class="doctools_section"><h2><a name="section4">HISTORY</a></h2> |
||||
<p>Some of the code in this extension is copied from Michael Miller's tcludp |
||||
package. (http://www.neosoft.com/tcl/ftparchive/sorted/comm/tcludp-1.0/) |
||||
Compared with Michael's UDP extension, this extension provides Windows |
||||
support and provides the ability of using 'gets/puts' to read/write |
||||
the socket. In addition, it provides more configuration ability.</p> |
||||
<p>Enhancements to support binary data and to setup the package for the Tcl |
||||
Extension Architecture by Pat Thoyts.</p> |
||||
<p>Support for IPv6 and allowing a multicast join on a specific network interface is added by Huub Eikens.</p> |
||||
</div> |
||||
<div id="see-also" class="doctools_section"><h2><a name="see-also">See Also</a></h2> |
||||
<p>socket</p> |
||||
</div> |
||||
<div id="keywords" class="doctools_section"><h2><a name="keywords">Keywords</a></h2> |
||||
<p>I/O, IP Address, TclUDP, UDP, asynchronous I/O, bind, channel, connection, domain, host, name, network, network address, networking, socket, udp</p> |
||||
</div> |
||||
<div id="copyright" class="doctools_section"><h2><a name="copyright">Copyright</a></h2> |
||||
<p>Copyright © 1999-2000 Columbia University; all rights reserved</p> |
||||
</div> |
||||
</div></body></html> |
||||
Binary file not shown.
@ -1,2 +0,0 @@
|
||||
package ifneeded udp 1.0.12 \ |
||||
[list load [file join $dir udp1012.dll]] |
||||
Binary file not shown.
Loading…
Reference in new issue