Procedures to convert numbers and bytes to
internet-host-addresses. Added fd->port. Small bug-fixes.
This commit is contained in:
parent
e57f3608b8
commit
50664556eb
321
scsh/network.c
321
scsh/network.c
|
@ -36,38 +36,6 @@ s48_value df_socket(s48_value g1, s48_value g2, s48_value g3, s48_value mv_vec)
|
|||
return ret1;
|
||||
}
|
||||
|
||||
s48_value df_scheme_bind(s48_value g1, s48_value g2, s48_value g3)
|
||||
{
|
||||
extern int scheme_bind(int , int , s48_value );
|
||||
s48_value ret1;
|
||||
S48_DECLARE_GC_PROTECT(1);
|
||||
int r1;
|
||||
|
||||
|
||||
|
||||
S48_GC_PROTECT_1(ret1);
|
||||
r1 = scheme_bind(s48_extract_fixnum(g1), s48_extract_fixnum(g2), g3);
|
||||
ret1 = errno_or_false(r1);
|
||||
S48_GC_UNPROTECT();
|
||||
return ret1;
|
||||
}
|
||||
|
||||
s48_value df_scheme_connect(s48_value g1, s48_value g2, s48_value g3)
|
||||
{
|
||||
extern int scheme_connect(int , int , s48_value );
|
||||
s48_value ret1;
|
||||
S48_DECLARE_GC_PROTECT(1);
|
||||
int r1;
|
||||
|
||||
|
||||
|
||||
S48_GC_PROTECT_1(ret1);
|
||||
r1 = scheme_connect(s48_extract_fixnum(g1), s48_extract_fixnum(g2), g3);
|
||||
ret1 = errno_or_false(r1);
|
||||
S48_GC_UNPROTECT();
|
||||
return ret1;
|
||||
}
|
||||
|
||||
s48_value df_listen(s48_value g1, s48_value g2)
|
||||
{
|
||||
|
||||
|
@ -84,55 +52,6 @@ s48_value df_listen(s48_value g1, s48_value g2)
|
|||
return ret1;
|
||||
}
|
||||
|
||||
s48_value df_scheme_accept(s48_value g1, s48_value g2, s48_value g3, s48_value mv_vec)
|
||||
{
|
||||
extern int scheme_accept(int , int , s48_value );
|
||||
s48_value ret1;
|
||||
S48_DECLARE_GC_PROTECT(2);
|
||||
int r1;
|
||||
|
||||
|
||||
|
||||
S48_GC_PROTECT_2(mv_vec,ret1);
|
||||
r1 = scheme_accept(s48_extract_fixnum(g1), s48_extract_fixnum(g2), g3);
|
||||
ret1 = errno_or_false(r1);
|
||||
S48_VECTOR_SET(mv_vec,0,s48_enter_fixnum(r1));
|
||||
S48_GC_UNPROTECT();
|
||||
return ret1;
|
||||
}
|
||||
|
||||
s48_value df_scheme_peer_name(s48_value g1, s48_value g2, s48_value g3)
|
||||
{
|
||||
extern int scheme_peer_name(int , int , s48_value );
|
||||
s48_value ret1;
|
||||
S48_DECLARE_GC_PROTECT(1);
|
||||
int r1;
|
||||
|
||||
|
||||
|
||||
S48_GC_PROTECT_1(ret1);
|
||||
r1 = scheme_peer_name(s48_extract_fixnum(g1), s48_extract_fixnum(g2), g3);
|
||||
ret1 = errno_or_false(r1);
|
||||
S48_GC_UNPROTECT();
|
||||
return ret1;
|
||||
}
|
||||
|
||||
s48_value df_scheme_socket_name(s48_value g1, s48_value g2, s48_value g3)
|
||||
{
|
||||
extern int scheme_socket_name(int , int , s48_value );
|
||||
s48_value ret1;
|
||||
S48_DECLARE_GC_PROTECT(1);
|
||||
int r1;
|
||||
|
||||
|
||||
|
||||
S48_GC_PROTECT_1(ret1);
|
||||
r1 = scheme_socket_name(s48_extract_fixnum(g1), s48_extract_fixnum(g2), g3);
|
||||
ret1 = False_on_zero(r1);
|
||||
S48_GC_UNPROTECT();
|
||||
return ret1;
|
||||
}
|
||||
|
||||
s48_value df_shutdown(s48_value g1, s48_value g2)
|
||||
{
|
||||
extern int shutdown(int , int );
|
||||
|
@ -169,40 +88,6 @@ s48_value df_scheme_socket_pair(s48_value g1, s48_value mv_vec)
|
|||
return ret1;
|
||||
}
|
||||
|
||||
s48_value df_recv_substring(s48_value g1, s48_value g2, s48_value g3, s48_value g4, s48_value g5, s48_value g6, s48_value mv_vec)
|
||||
{
|
||||
extern ssize_t recv_substring(int , int , s48_value , size_t , size_t , s48_value );
|
||||
s48_value ret1;
|
||||
S48_DECLARE_GC_PROTECT(2);
|
||||
ssize_t r1;
|
||||
|
||||
|
||||
|
||||
S48_GC_PROTECT_2(mv_vec,ret1);
|
||||
r1 = recv_substring(s48_extract_fixnum(g1), s48_extract_fixnum(g2), g3, s48_extract_fixnum(g4), s48_extract_fixnum(g5), g6);
|
||||
ret1 = errno_or_false(r1);
|
||||
S48_VECTOR_SET(mv_vec,0,s48_enter_fixnum(r1));
|
||||
S48_GC_UNPROTECT();
|
||||
return ret1;
|
||||
}
|
||||
|
||||
s48_value df_send_substring(s48_value g1, s48_value g2, s48_value g3, s48_value g4, s48_value g5, s48_value g6, s48_value g7, s48_value mv_vec)
|
||||
{
|
||||
extern ssize_t send_substring(int , int , s48_value , size_t , size_t , int , s48_value );
|
||||
s48_value ret1;
|
||||
S48_DECLARE_GC_PROTECT(2);
|
||||
ssize_t r1;
|
||||
|
||||
|
||||
|
||||
S48_GC_PROTECT_2(mv_vec,ret1);
|
||||
r1 = send_substring(s48_extract_fixnum(g1), s48_extract_fixnum(g2), g3, s48_extract_fixnum(g4), s48_extract_fixnum(g5), s48_extract_fixnum(g6), g7);
|
||||
ret1 = errno_or_false(r1);
|
||||
S48_VECTOR_SET(mv_vec,0,s48_enter_fixnum(r1));
|
||||
S48_GC_UNPROTECT();
|
||||
return ret1;
|
||||
}
|
||||
|
||||
s48_value df_scheme_getsockopt(s48_value g1, s48_value g2, s48_value g3, s48_value mv_vec)
|
||||
{
|
||||
extern int scheme_getsockopt(int , int , int );
|
||||
|
@ -306,182 +191,6 @@ s48_value df_scheme_setsockopt_timeout(s48_value g1, s48_value g2, s48_value g3,
|
|||
return ret1;
|
||||
}
|
||||
|
||||
s48_value df_scheme_host_address2host_info(s48_value g1, s48_value mv_vec)
|
||||
{
|
||||
extern int scheme_host_address2host_info(s48_value , char **, char** *, char** *);
|
||||
s48_value ret1;
|
||||
S48_DECLARE_GC_PROTECT(2);
|
||||
int r1;
|
||||
char *r2;
|
||||
char** r3;
|
||||
char** r4;
|
||||
|
||||
|
||||
|
||||
S48_GC_PROTECT_2(mv_vec,ret1);
|
||||
r1 = scheme_host_address2host_info(g1, &r2, &r3, &r4);
|
||||
ret1 = False_on_zero(r1);
|
||||
SetAlienVal(S48_CAR(S48_VECTOR_REF(mv_vec,0)),(long) r2); S48_SET_CDR(S48_VECTOR_REF(mv_vec,0),strlen_or_false(r2));//str-and-len
|
||||
SetAlienVal(S48_VECTOR_REF(mv_vec,1),(long) r3);//simple-assign
|
||||
SetAlienVal(S48_VECTOR_REF(mv_vec,2),(long) r4);//simple-assign
|
||||
S48_GC_UNPROTECT();
|
||||
return ret1;
|
||||
}
|
||||
|
||||
s48_value df_scheme_host_name2host_info(s48_value g1, s48_value mv_vec)
|
||||
{
|
||||
extern int scheme_host_name2host_info(const char *, char **, char** *, char** *);
|
||||
s48_value ret1;
|
||||
S48_DECLARE_GC_PROTECT(2);
|
||||
int r1;
|
||||
char *r2;
|
||||
char** r3;
|
||||
char** r4;
|
||||
|
||||
|
||||
|
||||
S48_GC_PROTECT_2(mv_vec,ret1);
|
||||
r1 = scheme_host_name2host_info(s48_extract_string(g1), &r2, &r3, &r4);
|
||||
ret1 = False_on_zero(r1);
|
||||
SetAlienVal(S48_CAR(S48_VECTOR_REF(mv_vec,0)),(long) r2); S48_SET_CDR(S48_VECTOR_REF(mv_vec,0),strlen_or_false(r2));//str-and-len
|
||||
SetAlienVal(S48_VECTOR_REF(mv_vec,1),(long) r3);//simple-assign
|
||||
SetAlienVal(S48_VECTOR_REF(mv_vec,2),(long) r4);//simple-assign
|
||||
S48_GC_UNPROTECT();
|
||||
return ret1;
|
||||
}
|
||||
|
||||
s48_value df_scheme_net_address2net_info(s48_value g1, s48_value g2, s48_value mv_vec)
|
||||
{
|
||||
extern int scheme_net_address2net_info(s48_value , s48_value , char **, char** *);
|
||||
s48_value ret1;
|
||||
S48_DECLARE_GC_PROTECT(2);
|
||||
int r1;
|
||||
char *r2;
|
||||
char** r3;
|
||||
|
||||
|
||||
|
||||
S48_GC_PROTECT_2(mv_vec,ret1);
|
||||
r1 = scheme_net_address2net_info(g1, g2, &r2, &r3);
|
||||
ret1 = False_on_zero(r1);
|
||||
SetAlienVal(S48_CAR(S48_VECTOR_REF(mv_vec,0)),(long) r2); S48_SET_CDR(S48_VECTOR_REF(mv_vec,0),strlen_or_false(r2));//str-and-len
|
||||
SetAlienVal(S48_VECTOR_REF(mv_vec,1),(long) r3);//simple-assign
|
||||
S48_GC_UNPROTECT();
|
||||
return ret1;
|
||||
}
|
||||
|
||||
s48_value df_scheme_net_name2net_info(s48_value g1, s48_value g2, s48_value mv_vec)
|
||||
{
|
||||
extern int scheme_net_name2net_info(const char *, s48_value , char **, char** *);
|
||||
s48_value ret1;
|
||||
S48_DECLARE_GC_PROTECT(2);
|
||||
int r1;
|
||||
char *r2;
|
||||
char** r3;
|
||||
|
||||
|
||||
|
||||
S48_GC_PROTECT_2(mv_vec,ret1);
|
||||
r1 = scheme_net_name2net_info(s48_extract_string(g1), g2, &r2, &r3);
|
||||
ret1 = False_on_zero(r1);
|
||||
SetAlienVal(S48_CAR(S48_VECTOR_REF(mv_vec,0)),(long) r2); S48_SET_CDR(S48_VECTOR_REF(mv_vec,0),strlen_or_false(r2));//str-and-len
|
||||
SetAlienVal(S48_VECTOR_REF(mv_vec,1),(long) r3);//simple-assign
|
||||
S48_GC_UNPROTECT();
|
||||
return ret1;
|
||||
}
|
||||
|
||||
s48_value df_scheme_serv_port2serv_info(s48_value g1, s48_value g2, s48_value mv_vec)
|
||||
{
|
||||
extern int scheme_serv_port2serv_info(int , const char *, char **, char** *, int *, char **);
|
||||
s48_value ret1;
|
||||
S48_DECLARE_GC_PROTECT(2);
|
||||
int r1;
|
||||
char *r2;
|
||||
char** r3;
|
||||
int r4;
|
||||
char *r5;
|
||||
|
||||
|
||||
|
||||
S48_GC_PROTECT_2(mv_vec,ret1);
|
||||
r1 = scheme_serv_port2serv_info(s48_extract_fixnum(g1), s48_extract_string(g2), &r2, &r3, &r4, &r5);
|
||||
ret1 = False_on_zero(r1);
|
||||
SetAlienVal(S48_CAR(S48_VECTOR_REF(mv_vec,0)),(long) r2); S48_SET_CDR(S48_VECTOR_REF(mv_vec,0),strlen_or_false(r2));//str-and-len
|
||||
SetAlienVal(S48_VECTOR_REF(mv_vec,1),(long) r3);//simple-assign
|
||||
S48_VECTOR_SET(mv_vec,2,s48_enter_fixnum(r4));
|
||||
SetAlienVal(S48_CAR(S48_VECTOR_REF(mv_vec,3)),(long) r5); S48_SET_CDR(S48_VECTOR_REF(mv_vec,3),strlen_or_false(r5));//str-and-len
|
||||
S48_GC_UNPROTECT();
|
||||
return ret1;
|
||||
}
|
||||
|
||||
s48_value df_scheme_serv_name2serv_info(s48_value g1, s48_value g2, s48_value mv_vec)
|
||||
{
|
||||
extern int scheme_serv_name2serv_info(const char *, const char *, char **, char** *, int *, char **);
|
||||
s48_value ret1;
|
||||
S48_DECLARE_GC_PROTECT(2);
|
||||
int r1;
|
||||
char *r2;
|
||||
char** r3;
|
||||
int r4;
|
||||
char *r5;
|
||||
|
||||
|
||||
|
||||
S48_GC_PROTECT_2(mv_vec,ret1);
|
||||
r1 = scheme_serv_name2serv_info(s48_extract_string(g1), s48_extract_string(g2), &r2, &r3, &r4, &r5);
|
||||
ret1 = False_on_zero(r1);
|
||||
SetAlienVal(S48_CAR(S48_VECTOR_REF(mv_vec,0)),(long) r2); S48_SET_CDR(S48_VECTOR_REF(mv_vec,0),strlen_or_false(r2));//str-and-len
|
||||
SetAlienVal(S48_VECTOR_REF(mv_vec,1),(long) r3);//simple-assign
|
||||
S48_VECTOR_SET(mv_vec,2,s48_enter_fixnum(r4));
|
||||
SetAlienVal(S48_CAR(S48_VECTOR_REF(mv_vec,3)),(long) r5); S48_SET_CDR(S48_VECTOR_REF(mv_vec,3),strlen_or_false(r5));//str-and-len
|
||||
S48_GC_UNPROTECT();
|
||||
return ret1;
|
||||
}
|
||||
|
||||
s48_value df_scheme_proto_num2proto_info(s48_value g1, s48_value mv_vec)
|
||||
{
|
||||
extern int scheme_proto_num2proto_info(int , char **, char** *, int *);
|
||||
s48_value ret1;
|
||||
S48_DECLARE_GC_PROTECT(2);
|
||||
int r1;
|
||||
char *r2;
|
||||
char** r3;
|
||||
int r4;
|
||||
|
||||
|
||||
|
||||
S48_GC_PROTECT_2(mv_vec,ret1);
|
||||
r1 = scheme_proto_num2proto_info(s48_extract_fixnum(g1), &r2, &r3, &r4);
|
||||
ret1 = False_on_zero(r1);
|
||||
SetAlienVal(S48_CAR(S48_VECTOR_REF(mv_vec,0)),(long) r2); S48_SET_CDR(S48_VECTOR_REF(mv_vec,0),strlen_or_false(r2));//str-and-len
|
||||
SetAlienVal(S48_VECTOR_REF(mv_vec,1),(long) r3);//simple-assign
|
||||
S48_VECTOR_SET(mv_vec,2,s48_enter_fixnum(r4));
|
||||
S48_GC_UNPROTECT();
|
||||
return ret1;
|
||||
}
|
||||
|
||||
s48_value df_scheme_proto_name2proto_info(s48_value g1, s48_value mv_vec)
|
||||
{
|
||||
extern int scheme_proto_name2proto_info(const char *, char **, char** *, int *);
|
||||
s48_value ret1;
|
||||
S48_DECLARE_GC_PROTECT(2);
|
||||
int r1;
|
||||
char *r2;
|
||||
char** r3;
|
||||
int r4;
|
||||
|
||||
|
||||
|
||||
S48_GC_PROTECT_2(mv_vec,ret1);
|
||||
r1 = scheme_proto_name2proto_info(s48_extract_string(g1), &r2, &r3, &r4);
|
||||
ret1 = False_on_zero(r1);
|
||||
SetAlienVal(S48_CAR(S48_VECTOR_REF(mv_vec,0)),(long) r2); S48_SET_CDR(S48_VECTOR_REF(mv_vec,0),strlen_or_false(r2));//str-and-len
|
||||
SetAlienVal(S48_VECTOR_REF(mv_vec,1),(long) r3);//simple-assign
|
||||
S48_VECTOR_SET(mv_vec,2,s48_enter_fixnum(r4));
|
||||
S48_GC_UNPROTECT();
|
||||
return ret1;
|
||||
}
|
||||
|
||||
s48_value df_veclen(s48_value g1)
|
||||
{
|
||||
extern s48_value veclen(const long * );
|
||||
|
@ -510,30 +219,30 @@ s48_value df_set_longvec_carriers(s48_value g1, s48_value g2)
|
|||
s48_value s48_init_network(void)
|
||||
{
|
||||
S48_EXPORT_FUNCTION(df_socket);
|
||||
S48_EXPORT_FUNCTION(df_scheme_bind);
|
||||
S48_EXPORT_FUNCTION(df_scheme_connect);
|
||||
S48_EXPORT_FUNCTION(scheme_bind);
|
||||
S48_EXPORT_FUNCTION(scheme_connect);
|
||||
S48_EXPORT_FUNCTION(df_listen);
|
||||
S48_EXPORT_FUNCTION(df_scheme_accept);
|
||||
S48_EXPORT_FUNCTION(df_scheme_peer_name);
|
||||
S48_EXPORT_FUNCTION(df_scheme_socket_name);
|
||||
S48_EXPORT_FUNCTION(scheme_accept);
|
||||
S48_EXPORT_FUNCTION(scheme_peer_name);
|
||||
S48_EXPORT_FUNCTION(scheme_socket_name);
|
||||
S48_EXPORT_FUNCTION(df_shutdown);
|
||||
S48_EXPORT_FUNCTION(df_scheme_socket_pair);
|
||||
S48_EXPORT_FUNCTION(df_recv_substring);
|
||||
S48_EXPORT_FUNCTION(df_send_substring);
|
||||
S48_EXPORT_FUNCTION(recv_substring);
|
||||
S48_EXPORT_FUNCTION(send_substring);
|
||||
S48_EXPORT_FUNCTION(df_scheme_getsockopt);
|
||||
S48_EXPORT_FUNCTION(df_scheme_getsockopt_linger);
|
||||
S48_EXPORT_FUNCTION(df_scheme_getsockopt_timeout);
|
||||
S48_EXPORT_FUNCTION(df_scheme_setsockopt);
|
||||
S48_EXPORT_FUNCTION(df_scheme_setsockopt_linger);
|
||||
S48_EXPORT_FUNCTION(df_scheme_setsockopt_timeout);
|
||||
S48_EXPORT_FUNCTION(df_scheme_host_address2host_info);
|
||||
S48_EXPORT_FUNCTION(df_scheme_host_name2host_info);
|
||||
S48_EXPORT_FUNCTION(df_scheme_net_address2net_info);
|
||||
S48_EXPORT_FUNCTION(df_scheme_net_name2net_info);
|
||||
S48_EXPORT_FUNCTION(df_scheme_serv_port2serv_info);
|
||||
S48_EXPORT_FUNCTION(df_scheme_serv_name2serv_info);
|
||||
S48_EXPORT_FUNCTION(df_scheme_proto_num2proto_info);
|
||||
S48_EXPORT_FUNCTION(df_scheme_proto_name2proto_info);
|
||||
S48_EXPORT_FUNCTION(scheme_host_address2host_info);
|
||||
S48_EXPORT_FUNCTION(scheme_host_name2host_info);
|
||||
S48_EXPORT_FUNCTION(scheme_net_address2net_info);
|
||||
S48_EXPORT_FUNCTION(scheme_net_name2net_info);
|
||||
S48_EXPORT_FUNCTION(scheme_serv_port2serv_info);
|
||||
S48_EXPORT_FUNCTION(scheme_serv_name2serv_info);
|
||||
S48_EXPORT_FUNCTION(scheme_proto_num2proto_info);
|
||||
S48_EXPORT_FUNCTION(scheme_proto_name2proto_info);
|
||||
S48_EXPORT_FUNCTION(df_veclen);
|
||||
S48_EXPORT_FUNCTION(df_set_longvec_carriers);
|
||||
|
||||
|
|
|
@ -38,9 +38,7 @@
|
|||
(byte-vector-set! bv 3 (bitwise-and (arithmetic-shift number -24) #xff))
|
||||
bv))
|
||||
|
||||
(set! internet-address/any (integer->byte-vector internet-address/any ))
|
||||
(set! internet-address/loopback (integer->byte-vector internet-address/loopback ))
|
||||
(set! internet-address/broadcast (integer->byte-vector internet-address/broadcast ))
|
||||
|
||||
;;;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|
||||
;;; High Level Prototypes
|
||||
;;;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|
||||
|
@ -131,6 +129,33 @@
|
|||
;;;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|
||||
;;; Socket Address Routines
|
||||
;;;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|
||||
(define (internet-host-address-from-number address32)
|
||||
(integer->byte-vector address32))
|
||||
|
||||
(define (internet-host-address-from-bytes b4 b3 b2 b1)
|
||||
(let ((bv (make-byte-vector 4 0)))
|
||||
(byte-vector-set! bv 0 b1)
|
||||
(byte-vector-set! bv 1 b2)
|
||||
(byte-vector-set! bv 2 b3)
|
||||
(byte-vector-set! bv 3 b4)
|
||||
bv))
|
||||
|
||||
(define (internet-host-address-to-bytes address)
|
||||
(list (byte-vector-ref address 3)
|
||||
(byte-vector-ref address 2)
|
||||
(byte-vector-ref address 1)
|
||||
(byte-vector-ref address 0)))
|
||||
|
||||
(define (internet-host-address-to-number address)
|
||||
(byte-vector->integer address))
|
||||
|
||||
(set! internet-address/any
|
||||
(internet-host-address-from-number internet-address/any ))
|
||||
(set! internet-address/loopback
|
||||
(internet-host-address-from-number internet-address/loopback ))
|
||||
(set! internet-address/broadcast
|
||||
(internet-host-address-from-number internet-address/broadcast ))
|
||||
|
||||
(define (internet-address->socket-address address32 port16)
|
||||
(cond ((not (and (byte-vector? address32)
|
||||
(= (byte-vector-length address32) 4)))
|
||||
|
@ -187,6 +212,18 @@
|
|||
(set-fdes-status out open/non-blocking)
|
||||
(make-socket pf in out)))))
|
||||
|
||||
|
||||
;;; Turn a file descriptor into a socket.
|
||||
;;; Useful if running as inetd-child
|
||||
|
||||
(define (fd->socket fd pf)
|
||||
(let* ((in (make-input-fdport fd 0))
|
||||
(out (dup->outport in)))
|
||||
(set-fdes-status fd open/non-blocking) ; this raises an error if fd was not
|
||||
; a socket
|
||||
(set-fdes-status out open/non-blocking)
|
||||
(make-socket pf in out)))
|
||||
|
||||
(define-foreign %socket/errno
|
||||
(socket (fixnum pf)
|
||||
(fixnum type)
|
||||
|
@ -513,21 +550,21 @@
|
|||
((not (string? s))
|
||||
(error "send-message: string expected ~s" s))
|
||||
(else
|
||||
(generic-send-message (socket->fdes socket) flags
|
||||
(generic-send-message socket flags
|
||||
s start end
|
||||
send-substring
|
||||
(if addr (socket-address:family addr) 0)
|
||||
(if addr (socket-address:address addr) #f))))))
|
||||
|
||||
(define (generic-send-message sockfd flags s start end writer family addr)
|
||||
(define (generic-send-message socket flags s start end writer family addr)
|
||||
(if (bogus-substring-spec? s start end)
|
||||
(error "Bad substring indices"
|
||||
sockfd flags family addr
|
||||
socket flags family addr
|
||||
s start end writer))
|
||||
|
||||
(let loop ((i start))
|
||||
(if (< i end)
|
||||
(loop (+ i (writer sockfd flags s i end family addr))))))
|
||||
(loop (+ i (writer socket flags s i end family addr))))))
|
||||
|
||||
|
||||
(define (send-message/partial socket s . args)
|
||||
|
@ -539,7 +576,7 @@
|
|||
((not (string? s))
|
||||
(error "send-message/partial: string expected ~s" s))
|
||||
(else
|
||||
(generic-send-message/partial (socket->fdes socket) flags
|
||||
(generic-send-message/partial socket flags
|
||||
s start end
|
||||
send-substring
|
||||
(if addr (socket-address:family addr) 0)
|
||||
|
@ -547,20 +584,21 @@
|
|||
(socket-address:address addr)
|
||||
#f))))))
|
||||
|
||||
(define (generic-send-message/partial sockfd flags s start end writer family
|
||||
(define (generic-send-message/partial socket flags s start end writer family
|
||||
addr)
|
||||
(if (bogus-substring-spec? s start end)
|
||||
(error "Bad substring indices"
|
||||
sockfd flags family addr
|
||||
socket flags family addr
|
||||
s start end writer))
|
||||
(if (= start end)
|
||||
0 ; Vacuous request.
|
||||
(writer sockfd flags s start end family addr)))
|
||||
(writer socket flags s start end family addr)))
|
||||
|
||||
(define (send-substring sockfd flags buf start end family name)
|
||||
(define (send-substring socket flags buf start end family name)
|
||||
(let loop ()
|
||||
((structure-ref interrupts disable-interrupts!))
|
||||
(cond ((%send-substring sockfd flags buf start end family name)
|
||||
(cond ((%send-substring (socket->fdes socket) flags buf start end
|
||||
family name)
|
||||
=> (lambda (nwritten)
|
||||
((structure-ref interrupts
|
||||
enable-interrupts!))
|
||||
|
|
|
@ -164,7 +164,7 @@ s48_value scheme_accept(s48_value sockfd_tagged, s48_value family)
|
|||
case AF_UNIX:
|
||||
{
|
||||
struct sockaddr_un name;
|
||||
size_t namelen=sizeof(name);
|
||||
socklen_t namelen=sizeof(name);
|
||||
int newsockfd=accept(sockfd,(struct sockaddr *)&name,&namelen);
|
||||
|
||||
if (newsockfd < 0)
|
||||
|
@ -182,7 +182,7 @@ s48_value scheme_accept(s48_value sockfd_tagged, s48_value family)
|
|||
case AF_INET:
|
||||
{
|
||||
struct sockaddr_in name;
|
||||
int namelen=sizeof(name);
|
||||
socklen_t namelen=sizeof(name);
|
||||
int newsockfd;
|
||||
s48_value result, sock_addr;
|
||||
S48_DECLARE_GC_PROTECT(2);
|
||||
|
@ -235,7 +235,7 @@ s48_value scheme_peer_name(s48_value sock, s48_value family)
|
|||
case AF_INET:
|
||||
{
|
||||
struct sockaddr_in name;
|
||||
int namelen=sizeof(name);
|
||||
socklen_t namelen=sizeof(name);
|
||||
int value=getpeername(sockfd,(struct sockaddr *)&name,&namelen);
|
||||
|
||||
if (value < 0) s48_raise_os_error (errno);
|
||||
|
@ -257,7 +257,7 @@ s48_value scheme_socket_name(s48_value sock, s48_value family)
|
|||
case AF_INET:
|
||||
{
|
||||
struct sockaddr_in name;
|
||||
int namelen=sizeof(name);
|
||||
socklen_t namelen=sizeof(name);
|
||||
int value=getsockname(sockfd,(struct sockaddr *)&name,&namelen);
|
||||
|
||||
if (value < 0) s48_raise_os_error (errno);
|
||||
|
@ -289,7 +289,7 @@ recv_substring(s48_value scm_sockfd, s48_value flags, s48_value buf,
|
|||
s48_value scm_start, s48_value scm_end)
|
||||
{
|
||||
struct sockaddr_in name;
|
||||
int namelen=sizeof(name);
|
||||
socklen_t namelen=sizeof(name);
|
||||
int sockfd = s48_extract_fixnum (scm_sockfd);
|
||||
int start = s48_extract_fixnum (scm_start);
|
||||
int end = s48_extract_fixnum (scm_end);
|
||||
|
|
|
@ -647,6 +647,7 @@
|
|||
unix-address->socket-address
|
||||
socket-address->unix-address
|
||||
create-socket
|
||||
fd->socket
|
||||
close-socket
|
||||
bind-socket
|
||||
connect-socket
|
||||
|
@ -664,6 +665,10 @@
|
|||
send-message/partial
|
||||
socket-option
|
||||
set-socket-option
|
||||
internet-host-address-from-number
|
||||
internet-host-address-from-bytes
|
||||
internet-host-address-to-number
|
||||
internet-host-address-to-bytes
|
||||
|
||||
host-info
|
||||
host-info?
|
||||
|
|
|
@ -204,6 +204,7 @@
|
|||
command-processor
|
||||
escapes
|
||||
i/o ; S48's force-output
|
||||
exceptions ; signal-exception
|
||||
formats
|
||||
threads-internal
|
||||
records ; I don't think this is necessary. !!!
|
||||
|
@ -415,6 +416,7 @@
|
|||
(open enumerated
|
||||
locks
|
||||
error-package
|
||||
i/o ;current-error-port
|
||||
interrupts ; signal handler code
|
||||
scheme
|
||||
threads-internal
|
||||
|
|
Loading…
Reference in New Issue