summaryrefslogtreecommitdiff
path: root/src/conn-tools/s6-tcpserver4d.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/conn-tools/s6-tcpserver4d.c')
-rw-r--r--src/conn-tools/s6-tcpserver4d.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/conn-tools/s6-tcpserver4d.c b/src/conn-tools/s6-tcpserver4d.c
index 914e981..3432236 100644
--- a/src/conn-tools/s6-tcpserver4d.c
+++ b/src/conn-tools/s6-tcpserver4d.c
@@ -10,6 +10,7 @@
#include <signal.h>
#include <skalibs/gccattributes.h>
#include <skalibs/allreadwrite.h>
+#include <skalibs/uint16.h>
#include <skalibs/types.h>
#include <skalibs/sgetopt.h>
#include <skalibs/strerr2.h>
@@ -333,7 +334,17 @@ int main (int argc, char const *const *argv, char const *const *envp)
}
if (flag1)
{
- fd_write(1, "\n", 1) ;
+ uint16_t port ;
+ uint16_t m = 0 ;
+ char ip[4] ;
+ char fmtport[UINT16_FMT] ;
+ if (socket_local4(0, ip, &port) == -1)
+ {
+ if (verbosity) strerr_warnwu1sys("socket_local4") ;
+ }
+ else m = uint16_fmt(fmtport, port) ;
+ fmtport[m++] = '\n' ;
+ allwrite(1, fmtport, m) ;
fd_close(1) ;
}
}