Tcl UDP

Check-in [908a32728e]
Login

Check-in [908a32728e]

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

Overview
Comment:SOCKET on 64-bit Windows is not a 32-bit int. Fix printfs accordingly.
Timelines: family | ancestors | descendants | both | nmake-rules-update
Files: files | file ages | folders
SHA1: 908a32728eb057b3239d10b91c4a0a6ca9c8aede
User & Date: apnadkarni 2017-08-26 13:50:56.531
Context
2017-08-26
14:17
Added -D _WINSOCK_DEPRECATED_NO_WARNING. We still support XP so forced to use deprecated Win32 functions. check-in: 955941c555 user: apnadkarni tags: nmake-rules-update
13:50
SOCKET on 64-bit Windows is not a 32-bit int. Fix printfs accordingly. check-in: 908a32728e user: apnadkarni tags: nmake-rules-update
2017-08-15
16:02
Updated nmake files to reflect current Tcl builds and support VS 2017. Fixed calls to Win32 since Tcl now defines UNICODE check-in: 469565623d user: apnadkarni tags: nmake-rules-update
Changes
Unified Diff Ignore Whitespace Patch
Changes to generic/udp_tcl.c.
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
    
    UDPTRACE("Open socket %d. Bind socket to port %d\n", 
             sock, ntohs(localport));

    statePtr = (UdpState *) ckalloc((unsigned) sizeof(UdpState));
    memset(statePtr, 0, sizeof(UdpState));
    statePtr->sock = sock;
    sprintf(channelName, "sock%d", statePtr->sock);
    statePtr->channel = Tcl_CreateChannel(&Udp_ChannelType, channelName,
                                          (ClientData) statePtr,
                                          (TCL_READABLE | TCL_WRITABLE | TCL_MODE_NONBLOCKING));
    statePtr->doread = 1;
    statePtr->multicast = 0;
    statePtr->groupsObj = Tcl_NewListObj(0, NULL);
    Tcl_IncrRefCount(statePtr->groupsObj);







|







374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
    
    UDPTRACE("Open socket %d. Bind socket to port %d\n", 
             sock, ntohs(localport));

    statePtr = (UdpState *) ckalloc((unsigned) sizeof(UdpState));
    memset(statePtr, 0, sizeof(UdpState));
    statePtr->sock = sock;
    sprintf(channelName, "sock" SOCKET_PRINTF_FMT, statePtr->sock);
    statePtr->channel = Tcl_CreateChannel(&Udp_ChannelType, channelName,
                                          (ClientData) statePtr,
                                          (TCL_READABLE | TCL_WRITABLE | TCL_MODE_NONBLOCKING));
    statePtr->doread = 1;
    statePtr->multicast = 0;
    statePtr->groupsObj = Tcl_NewListObj(0, NULL);
    Tcl_IncrRefCount(statePtr->groupsObj);
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
        errorCode = errno;
    }
    ckfree((char *) statePtr);
    if (errorCode != 0) {
#ifndef WIN32
        sprintf(errBuf, "udp_close: %d, error: %d\n", sock, errorCode);
#else
        sprintf(errBuf, "udp_cose: %d, error: %d\n", sock, WSAGetLastError());
#endif
        UDPTRACE("UDP error - close %d", sock);
    } else {
        UDPTRACE("Close socket %d\n", sock);
    }
    
#ifdef WIN32







|







945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
        errorCode = errno;
    }
    ckfree((char *) statePtr);
    if (errorCode != 0) {
#ifndef WIN32
        sprintf(errBuf, "udp_close: %d, error: %d\n", sock, errorCode);
#else
        sprintf(errBuf, "udp_close: " SOCKET_PRINTF_FMT ", error: %d\n", sock, WSAGetLastError());
#endif
        UDPTRACE("UDP error - close %d", sock);
    } else {
        UDPTRACE("Close socket %d\n", sock);
    }
    
#ifdef WIN32
Changes to generic/udp_tcl.h.
107
108
109
110
111
112
113







114
115
116
117
118
  Tcl_ThreadId      threadId;        /* for Tcl_ThreadAlert */
#endif
  short				ss_family;		 /* indicator set for ipv4 or ipv6 usage */
  int               multicast;       /* indicator set for multicast add */
  Tcl_Obj          *groupsObj;       /* list of the mcast groups */
} UdpState;









EXTERN int Udp_Init(Tcl_Interp *interp);
EXTERN int Udp_SafeInit(Tcl_Interp *interp);

#endif







>
>
>
>
>
>
>





107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
  Tcl_ThreadId      threadId;        /* for Tcl_ThreadAlert */
#endif
  short				ss_family;		 /* indicator set for ipv4 or ipv6 usage */
  int               multicast;       /* indicator set for multicast add */
  Tcl_Obj          *groupsObj;       /* list of the mcast groups */
} UdpState;


#if defined(WIN32) && defined(_M_AMD64)
# define SOCKET_PRINTF_FMT "%I64u"
#else
# define SOCKET_PRINTF_FMT "%d"
#endif


EXTERN int Udp_Init(Tcl_Interp *interp);
EXTERN int Udp_SafeInit(Tcl_Interp *interp);

#endif