[Toybox] [New Toys] - tcpsvd, udpsvd

ibid.ag at gmail.com ibid.ag at gmail.com
Thu Sep 26 09:44:42 PDT 2013


On Wed, Sep 25, 2013 at 05:57:49PM +0900, Ashwini Sharma wrote:
> Hi Rob, list,
> 
> Attached is the implementation of tcpsvd and udpsvd.
> Both the commands are handled in the same file and support __IPv4__ and
> __IPv6__.
> 
> Let me know for any comments and add it to the hg.
> 
> regards,
> Ashwini

> /* tcpsvd.c - TCP(UDP)/IP service daemon 
>  *
>  * Copyright 2013 Ashwini Kumar <ak.ashwini at gmail.com>
>  * Copyright 2013 Sandeep Sharma <sandeep.jack2756 at gmail.com>
>  * Copyright 2013 Kyungwan Han <asura321 at gmail.com>
>  * 
>  * No Standard.
> 
> USE_TCPSVD(NEWTOY(tcpsvd, "^<3c#=30<1C:b#=20<0u:l:hEv", TOYFLAG_USR|TOYFLAG_BIN))
> USE_TCPSVD(OLDTOY(udpsvd, tcpsvd, OPTSTR_tcpsvd, TOYFLAG_USR|TOYFLAG_BIN))
> 
> config TCPSVD
>   bool "tcpsvd"
>   default y
>   help
>     usage: tcpsvd [-hEv] [-c N] [-C N[:MSG]] [-b N] [-u User] [-l Name] IP Port Prog
>     udpsvd [-hEv] [-c N] [-u User] [-l Name] IP Port Prog
>     
>     Create TCP/UDP socket, bind to IP:PORT and listen for incoming connection. 
>     Run PROG for each connection.
> 
Out of curiousity, what does this do that the netcat "server options"
can't do?

Ah. Change user after bind, provide a limited number >1 of connections,
and set environment variables.
And I see that the command is from ipsvd, not homegrown.

Now, the second question...could any of this be shared with netcat?

>     IP            IP to listen on, 0 = all
>     PORT          Port to listen on
>     PROG ARGS     Program to run
>     -l NAME       Local hostname (else looks up local hostname in DNS)
>     -u USER[:GRP] Change to user/group after bind
>     -c N          Handle up to N (> 0) connections simultaneously
>     -b N          (TCP Only) Allow a backlog of approximately N TCP SYNs
>     -C N[:MSG]    (TCP Only) Allow only up to N (> 0) connections from the same IP
>                   New connections from this IP address are closed
>                   immediately. MSG is written to the peer before close
>     -h            Look up peer's hostname
>     -E            Don't set up environment variables
>     -v            Verbose
> */

On a cursory inspection, it doesn't look bad, though I have a suspicion
it could be more concise.

Thanks,
Isaac Dunham

 1380213882.0


More information about the Toybox mailing list