packages feed

libtelnet-0.1.0.0: README.md

# Bindings to libtelnet

This is a wrapper around
[libtelnet](https://github.com/seanmiddleditch/libtelnet), a C library
for handling Telnet streams, including option negotiation, &c. As a
cleartext protocol, Telnet is thorougly unsuitable for use on the open
internet, but you might have a niche where it makes sense:

* [MU*](https://en.wikipedia.org/wiki/MU*) games still use it, and so
  the clients people want to use only speak Telnet,
* You might be speaking Telnet inside a
  [stunnel](https://www.stunnel.org/), or
* You might have some ancient hardware that can't be updated, and
  doesn't have ssh, but you want to talk to it using Haskell.

This library hews closely to the interface provided by the C
libtelnet, so reading the [excellent C
documentation](https://github.com/seanmiddleditch/libtelnet#ii-api)
will help you. The short version goes something like this:

1. Define an _event handler_ of type
   `Network.Telnet.LibTelnet.EventHandler`. This function receives
   callbacks that tell you what received data should be propagated to
   the application, and what bytes need to be sent out over the
   socket.

2. Pass your event handler (and some other flags) to
   `Network.Telnet.LibTelnet.telnetInit`, which will give you access
   to a `Telnet`, a garbage-collected _state tracker_.

3. Tell the state tracker that data has arrived on the socket, or that
   you want to send data to the socket, by passing it to the library's
   other functions.

## Other Resources

* A simple server example exists in
  [`example/Main.hs`](https://git.sr.ht/~jack/libtelnet-haskell/tree/master/example/Main.hs).

* Questions should go to the
  [libtelnet-haskell-discuss](https://lists.sr.ht/~jack/libtelnet-haskell-discuss)
  mailing list.

* Bug reports should go to the
  [bug tracker](https://todo.sr.ht/~jack/libtelnet-haskell).