Tcl UDP

Check-in [c0eb8e4d18]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fixed dozy error on unix branch
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c0eb8e4d18d3fa7bcf423918690511788cacb682
User & Date: patthoyts 2007-04-10 23:49:38
Context
2007-04-11
00:06
Updated manual page. check-in: fb1cd1f6ab user: patthoyts tags: trunk
2007-04-10
23:49
Fixed dozy error on unix branch check-in: c0eb8e4d18 user: patthoyts tags: trunk
23:36
Use winsock2 so that mingw-gcc can get the correct values for multicast. check-in: 7f3b9d24cd user: patthoyts tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to demos/multicast.tcl.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
..
28
29
30
31
32
33
34
35
36

37
38
39
40
41
42
43
44
# multicast.tcl - Copyright (C) 2004 Pat Thoyts <[email protected]>
#
# 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.2 2005/05/19 15:41:06 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]
................................................................................
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 $group1 -remote [list $group1 $port]
fconfigure $s -mcastadd $group2 -remote [list $group2 $port]

fileevent $s readable [list udpEvent $s]

# Announce our presence and run
puts -nonewline $s "hello, world"
set forever 0
vwait ::forever

exit






|







 







<

>








1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
..
28
29
30
31
32
33
34

35
36
37
38
39
40
41
42
43
44
# multicast.tcl - Copyright (C) 2004 Pat Thoyts <[email protected]>
#
# 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]
................................................................................
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

Changes to generic/udp_tcl.c.

3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
....
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
 *
 * Copyright (c) 1999-2000 by Columbia University; all rights reserved
 * Copyright (c) 2003-2005 Pat Thoyts <[email protected]>
 *
 * Written by Xiaotao Wu
 * Last modified: 11/03/2000
 *
 * $Id: udp_tcl.c,v 1.39 2007/04/10 23:36:14 patthoyts Exp $
 ******************************************************************************/

#if defined(_DEBUG) && !defined(DEBUG)
#define DEBUG
#endif

#include "udp_tcl.h"
................................................................................
                         (LPWSTR)&sMsg, 0, NULL);
    errObj = Tcl_NewStringObj(prefix, -1);
    Tcl_AppendToObj(errObj, ": ", -1);
    Tcl_AppendUnicodeToObj(errObj, (LPWSTR)sMsg, len - 1);
    LocalFree(sMsg);
#elif defined(HAVE_STRERROR)
    extern int errno;
    Tcl_Obj *errObj = Tcl_NewStringObj(prefix, -1);
    Tcl_AppendStringsToObj(errObj, ": ", strerror(errno), NULL);
#endif
    return errObj;
}

/*
 * ----------------------------------------------------------------------






|







 







|







3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
....
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
 *
 * Copyright (c) 1999-2000 by Columbia University; all rights reserved
 * Copyright (c) 2003-2005 Pat Thoyts <[email protected]>
 *
 * Written by Xiaotao Wu
 * Last modified: 11/03/2000
 *
 * $Id: udp_tcl.c,v 1.40 2007/04/10 23:49:38 patthoyts Exp $
 ******************************************************************************/

#if defined(_DEBUG) && !defined(DEBUG)
#define DEBUG
#endif

#include "udp_tcl.h"
................................................................................
                         (LPWSTR)&sMsg, 0, NULL);
    errObj = Tcl_NewStringObj(prefix, -1);
    Tcl_AppendToObj(errObj, ": ", -1);
    Tcl_AppendUnicodeToObj(errObj, (LPWSTR)sMsg, len - 1);
    LocalFree(sMsg);
#elif defined(HAVE_STRERROR)
    extern int errno;
    errObj = Tcl_NewStringObj(prefix, -1);
    Tcl_AppendStringsToObj(errObj, ": ", strerror(errno), NULL);
#endif
    return errObj;
}

/*
 * ----------------------------------------------------------------------