Tcl UDP

Check-in [1b24c4d641]
Login

Check-in [1b24c4d641]

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

Overview
Comment:Checking in patch submitted to sourceforge: https://sourceforge.net/p/tcludp/bugs/42
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 1b24c4d6410fa2d28a44f9915af718a212a39aae
User & Date: hypnotoad 2014-08-21 14:32:56
Original User & Date: seandeelywoods 2014-08-21 14:32:56
Context
2014-08-29
15:01
Merging in updates from CVSHEAD check-in: 748bee8094 user: hypnotoad tags: trunk
2014-08-22
15:43
Branch to test specifying the interface to use for multicast check-in: ef5c5c83f4 user: hypnotoad tags: mcastif
2014-08-21
14:32
Checking in patch submitted to sourceforge: https://sourceforge.net/p/tcludp/bugs/42 check-in: 1b24c4d641 user: hypnotoad tags: trunk
14:18
Tweak to feed dtplite into TCLSH rathe than make a bare call. Some systems do not have "tclsh" provided as a bare command check-in: e8ca879427 user: hypnotoad tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/udp_tcl.c.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/******************************************************************************
 * UDP Extension for Tcl 8.4
 *
 * 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.46 2014/03/02 07:22:20 huubeikens Exp $
 ******************************************************************************/

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







|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/******************************************************************************
 * UDP Extension for Tcl 8.4
 *
 * Copyright (c) 1999-2000 by Columbia University; all rights reserved
 * Copyright (c) 2003-2005 Pat Thoyts <[email protected]>
 *
 * Written by Xiaotao Wu
 * Last modified: 08/21/2014
 *
 * $Id: udp_tcl.c,v 1.46 2014/03/02 07:22:20 huubeikens Exp $
 ******************************************************************************/

#if defined(_DEBUG) && !defined(DEBUG)
#define DEBUG
#endif
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118

1119
1120
1121
1122
1123
1124
1125
1126
     * blank every other call.  whenever the doread variable is 1 do
     * a normal read, otherwise just return 0.
     */
    if (statePtr->doread == 0) {
        statePtr->doread = 1;  /* next time we want to behave normally */
        *errorCode = EAGAIN;   /* pretend that we would block */
        UDPTRACE("Pretend we would block\n");
        return 0;
    }
    
    *errorCode = 0;
    errno = 0;
    
    if (bufSize == 0) {
        return 0;
    }
    
#ifdef WIN32
    packets = statePtr->packets;
    UDPTRACE("udp_recv\n");

    if (packets == NULL) {
        UDPTRACE("packets is NULL\n");

        return 0;
    }
    memcpy(buf, packets->message, packets->actual_size);
    ckfree((char *) packets->message);
    UDPTRACE("udp_recv message\n%s", buf);
    bufSize = packets->actual_size;
    strcpy(statePtr->peerhost, packets->r_host);
    statePtr->peerport = packets->r_port;







|















>
|







1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
     * blank every other call.  whenever the doread variable is 1 do
     * a normal read, otherwise just return 0.
     */
    if (statePtr->doread == 0) {
        statePtr->doread = 1;  /* next time we want to behave normally */
        *errorCode = EAGAIN;   /* pretend that we would block */
        UDPTRACE("Pretend we would block\n");
        return -1;
    }
    
    *errorCode = 0;
    errno = 0;
    
    if (bufSize == 0) {
        return 0;
    }
    
#ifdef WIN32
    packets = statePtr->packets;
    UDPTRACE("udp_recv\n");

    if (packets == NULL) {
        UDPTRACE("packets is NULL\n");
        *errorCode = EAGAIN;
        return -1;
    }
    memcpy(buf, packets->message, packets->actual_size);
    ckfree((char *) packets->message);
    UDPTRACE("udp_recv message\n%s", buf);
    bufSize = packets->actual_size;
    strcpy(statePtr->peerhost, packets->r_host);
    statePtr->peerport = packets->r_port;
1153
1154
1155
1156
1157
1158
1159
1160




1161
1162
1163
1164
1165
1166
1167
    /* we don't want to return anything next time */
    if (bytesRead > 0) {
        buf[bytesRead] = '\0';
        statePtr->doread = 0;
    }
    
    UDPTRACE("udpInput end: %d, %s\n", bytesRead, buf);
    




    if (bytesRead > -1) {
        return bytesRead;
    }
    
    *errorCode = errno;
    return -1;
}







|
>
>
>
>







1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
    /* we don't want to return anything next time */
    if (bytesRead > 0) {
        buf[bytesRead] = '\0';
        statePtr->doread = 0;
    }
    
    UDPTRACE("udpInput end: %d, %s\n", bytesRead, buf);

    if (bytesRead == 0) {
        *errorCode = EAGAIN;
        return -1;
    }
    if (bytesRead > -1) {
        return bytesRead;
    }
    
    *errorCode = errno;
    return -1;
}