Sockets
Brian Yennie
briany at qldlearning.com
Wed Mar 10 00:33:52 EST 2004
This is off the top of my head, but hopefully it helps. It basically
just expects 1 line of input over the socket, and then echos it back.
Note that you don't have to use the "with message" syntax, but if you
don't then your program will block when doing reads and writes from the
socket, which is bad if you need to handle multiple connections.
on startServer portNum
accept connections on port portNum with message "newConnect"
end startServer
on stopServer portNum
close socket (portNum)
on stopServer
on newConnect s
read from s for 1 line with message "firstLine"
end newConnect
on firstLine s,data
write "GOT IT::"&data to socket s with message "doneWriting"
end firstLine
on doneWriting s
close socket s
end doneWriting
on socketTimeout s
## a read or write timed out on this socket
end socketTimeout
on socketError s
## some other socket-related error
end socketError
> I am trying to put together some socket code on Windows. The
> documentation
> seems clear but there are a couple things that are not as I expected
> and a
> simple example would go a long way. Does anyone have such a thing
> handy?
> Just a simple "accept/connect, send/receive, close" example.
-------------------------------------
Brian Yennie
Chief Technology Officer
QLD Learning, LLC
(941)-362-3199
briany at qldlearning.com
--------------------------------------
More information about the use-livecode
mailing list