How to write a VERY simple server?

Mark Wieder mwieder at ahsoftware.net
Wed Aug 24 19:27:21 EDT 2005


Gajo-

Wednesday, August 24, 2005, 4:10:06 PM, you wrote:

> So could someone please just type down the source of a simple server
> script? On the Runtime's site they say you can write a client/server with
> just a few lines, so I'm sure it's very simple, but I cannot figure it out.

Try something like this...

accept connections on port 5001 with message "PortOpened"

-- PortOpened is called when someone connects
on PortOpened theSender, sentMessage
  local theMessage

  -- get a command from the client
  put empty into theMessage
  repeat while "Quit" is not in theMessage
    read from socket theSender until cr
    put it into theMessage
    if theMessage is not empty then
      switch word 1 of theMessage
        -- do something with the message here
      end switch
    end if
  end repeat
end PortOpened

-- 
-Mark Wieder
 mwieder at ahsoftware.net




More information about the use-livecode mailing list