From: patthoyts Date: Mon, 15 May 2006 14:35:24 +0000 (+0000) Subject: Fixed up some error messages. X-Git-Tag: tcludp-1_0_8~6 X-Git-Url: https://privyetmir.co.uk/gitweb.cgi?a=commitdiff_plain;h=38d6406d01c5444e4726019a06477d4bccdfbfa5;p=tcludp Fixed up some error messages. --- diff --git a/generic/udp_tcl.c b/generic/udp_tcl.c index 8245354..d578a1b 100644 --- a/generic/udp_tcl.c +++ b/generic/udp_tcl.c @@ -238,8 +238,9 @@ udpOpen(ClientData clientData, Tcl_Interp *interp, sock = socket(AF_INET, SOCK_DGRAM, 0); #endif if (sock < 0) { - sprintf(errBuf,"%s","udp - socket"); - UDPTRACE("UDP error - socket\n"); + snprintf(errBuf, 255, "failed to create socket"); + errBuf[255] = 0; + UDPTRACE("%s\n", errBuf); Tcl_AppendResult(interp, errBuf, (char *)NULL); return TCL_ERROR; } @@ -247,6 +248,7 @@ udpOpen(ClientData clientData, Tcl_Interp *interp, /* * bug #1477669: avoid socket inheritence after exec */ + #if HAVE_FLAG_FD_CLOEXEC fcntl(sock, F_SETFD, FD_CLOEXEC); #else @@ -268,8 +270,10 @@ udpOpen(ClientData clientData, Tcl_Interp *interp, addr.sin_port = localport; #endif if (bind(sock,(struct sockaddr *)&addr, sizeof(addr)) < 0) { - sprintf(errBuf,"%s","udp - bind"); - UDPTRACE("UDP error - bind\n"); + snprintf(errBuf, 255, "failed to bind socket to port %u", + ntohs(localport)); + errBuf[255] = 0; + UDPTRACE("%s\n"); Tcl_AppendResult(interp, errBuf, (char *)NULL); return TCL_ERROR; }