Monday, November 22, 2010

Creating servers in OS X

How to create a simple echo server in OS X. Assuming that you already have MacPorts installed (and if not, why not!), install xinetd as follows:
port install xinetd
Create the file
with the following contents:


Edit /etc/services to include the line:
myecho  7745/tcp # mcarter's weird nonsense
Edit /etc/xinetd.conf to include:
service myecho
        disable         = no
        socket_type     = stream
        wait            = no
        user            = root
        protocol        = tcp
        groups          = yes
        server          = /Users/mcarter/docs/echoserv/echoserv
        port    = 7745
Adjust the value of server to wherever you create echoserv. Create the file echoserv:
echo $REPLY
exit 0
Test it out:
telnet localhost 7745
hello world
It should print out hello world, and exit. Open port 7745 on your router, and you should be able to connect remotely.

1 comment:

Unknown said...

sweet thx, this is just what I needed to run this tutorial:

For me I had to run xinetd with sudo for it to work.