Skip to content

Commit

Permalink
Add IP to listen error message
Browse files Browse the repository at this point in the history
Patch by: michaelortmann
  • Loading branch information
michaelortmann authored Aug 1, 2024
1 parent 74c7861 commit a53587e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ char *iptostr(struct sockaddr *sa)
*/
int setsockname(sockname_t *addr, char *src, int port, int allowres)
{
char *endptr, *src2 = src;;
char *endptr, *src2 = src;
long val;
IP ip;
volatile int af = AF_UNSPEC;
Expand Down
17 changes: 12 additions & 5 deletions src/tcldcc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1176,15 +1176,22 @@ static int setlisten(Tcl_Interp *irp, char *ip, char *portp, char *type, char *m
if (strlen(newip)) {
setsockname(&name, newip, port, 1);
i = open_address_listen(&name);
if (i < 0) {
snprintf(msg, sizeof msg, "Couldn't listen on port %d on %s: %s. "
"Please check that the port is not already in use",
realport, newip, strerror(errno));
Tcl_AppendResult(irp, msg, NULL);
return TCL_ERROR;
}
} else {
i = open_listen(&port);
}
if (i < 0) {
egg_snprintf(msg, sizeof msg, "Couldn't listen on port '%d' on the given "
if (i < 0) {
snprintf(msg, sizeof msg, "Couldn't listen on port %d on the given "
"address: %s. Please check that the port is not already in use",
realport, strerror(errno));
Tcl_AppendResult(irp, msg, NULL);
return TCL_ERROR;
Tcl_AppendResult(irp, msg, NULL);
return TCL_ERROR;
}
}
idx = new_dcc(&DCC_TELNET, 0);
dcc[idx].sockname.addrlen = sizeof(dcc[idx].sockname.addr);
Expand Down

0 comments on commit a53587e

Please sign in to comment.