#lang scheme/base
(require scheme/tcp scheme/contract)
(define-struct client (host port in out (state #:mutable)))
(define (client-connect host port (state #f))
(let-values (((in out)
(tcp-connect host port)))
(make-client host port in out state)))
(define (client-disconnect client)
(close-input-port (client-in client))
(close-output-port (client-out client)))
(provide/contract
(struct client ((host string?)
(port exact-positive-integer?)
(in input-port?)
(out output-port?)
(state any/c)))
(client-connect (->* (string? exact-positive-integer?)
(any/c)
client?))
(client-disconnect (-> client? any))
)