mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-24 20:45:06 +02:00
Initial input/output port conversions
This commit is contained in:
parent
2205eedea9
commit
69795bfcd2
1 changed files with 16 additions and 4 deletions
20
srfi/106.sld
20
srfi/106.sld
|
@ -254,12 +254,24 @@
|
||||||
" close(obj_obj2int(sockfd));
|
" close(obj_obj2int(sockfd));
|
||||||
return_closcall1(data, k, boolean_t);")
|
return_closcall1(data, k, boolean_t);")
|
||||||
|
|
||||||
;; TODO: implement both of these:
|
;; TODO: may not be good enough, socket may be closed if file is closed
|
||||||
(define (socket-input-port sock)
|
(define (socket-input-port sock)
|
||||||
(error "Not implemented yet"))
|
(%socket-input-port (socket->fd sock)))
|
||||||
|
|
||||||
|
(define-c %socket-input-port
|
||||||
|
"(void *data, int argc, closure _, object k, object sockfd)"
|
||||||
|
" FILE *fp = fdopen(obj_obj2int(sockfd), \"r\");
|
||||||
|
make_port(port, fp, 1);
|
||||||
|
return_closcall1(data, k, &port);")
|
||||||
|
|
||||||
(define (socket-output-port sock)
|
(define (socket-output-port sock)
|
||||||
(error "Not implemented yet"))
|
(%socket-output-port (socket->fd sock)))
|
||||||
;; END TODO
|
|
||||||
|
(define-c %socket-output-port
|
||||||
|
"(void *data, int argc, closure _, object k, object sockfd)"
|
||||||
|
" FILE *fp = fdopen(obj_obj2int(sockfd), \"w\");
|
||||||
|
make_port(port, fp, 0);
|
||||||
|
return_closcall1(data, k, &port);")
|
||||||
|
|
||||||
(define (call-with-socket socket proc)
|
(define (call-with-socket socket proc)
|
||||||
(let ((result (proc socket)))
|
(let ((result (proc socket)))
|
||||||
|
|
Loading…
Add table
Reference in a new issue