Changeset 12481 in project for chicken/trunk


Ignore:
Timestamp:
11/12/08 10:37:52 (12 years ago)
Author:
felix winkelmann
Message:

some port checks for tcp operations [reported by Peter Bex]

File:
1 edited

Legend:

Unmodified
Added
Removed
  • chicken/trunk/tcp.scm

    r10712 r12481  
    598598
    599599(define (##sys#tcp-port->fileno p)
    600   (##sys#slot (##sys#port-data p) 0) )
     600  (let ((data (##sys#port-data p)))
     601    (if (vector? data)                  ; a meagre test, but better than nothing
     602        (##sys#slot data 0)
     603        (error '##sys#tcp-port->fileno "argument does not appear to be a TCP port" p))))
    601604
    602605(define (tcp-addresses p)
     606  (##sys#check-port p 'tcp-addresses)
    603607  (let ((fd (##sys#tcp-port->fileno p)))
    604608    (values
     
    609613
    610614(define (tcp-port-numbers p)
    611  (let ((fd (##sys#tcp-port->fileno p)))
    612    (values
    613     (or (##net#getsockport fd)
    614         (##sys#signal-hook #:network-error 'tcp-port-numbers (##sys#string-append "can not compute local port - " strerror) p) )
    615     (or (##net#getpeerport fd)
    616         (##sys#signal-hook #:network-error 'tcp-port-numbers (##sys#string-append "can not compute remote port - " strerror) p) ) ) ) )
     615  (##sys#check-port p 'tcp-port-numbers)
     616  (let ((fd (##sys#tcp-port->fileno p)))
     617    (values
     618     (or (##net#getsockport fd)
     619         (##sys#signal-hook #:network-error 'tcp-port-numbers (##sys#string-append "can not compute local port - " strerror) p) )
     620     (or (##net#getpeerport fd)
     621         (##sys#signal-hook #:network-error 'tcp-port-numbers (##sys#string-append "can not compute remote port - " strerror) p) ) ) ) )
    617622
    618623(define (tcp-listener-port tcpl)
Note: See TracChangeset for help on using the changeset viewer.