Changeset 21151 in project


Ignore:
Timestamp:
10/30/10 23:26:18 (11 years ago)
Author:
Moritz Heidkamp
Message:

zmq: fix silly bugs in socket-option and add socket-fd accessor

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/4/zmq/trunk/zmq.scm

    r21146 r21151  
    55 make-message message? message-size message->string copy-message
    66 make-socket socket? close-socket bind-socket connect-socket
    7  socket-option-set! socket-option
     7 socket-option-set! socket-option socket-fd
    88 send-message receive-message
    99 make-poll-item poll poll-item-socket
     
    268268
    269269(define (%socket-option socket option value size)
    270   (if (zero? ((foreign-lambda int zmq_getsockopt socket socket-option c-pointer c-pointer)
     270  (or (zero? ((foreign-lambda int zmq_getsockopt socket int c-pointer c-pointer)
    271271              (socket-pointer socket) option value size))
    272       value
    273272      (zmq-error 'socket-option)))
    274273
    275274(define (socket-option socket option)
    276275  (cond ((eq? option 'identity)
    277          (let-location ((value c-string*) (size unsigned-int))
    278            (%socket-option socket option (location value) (location size))))
     276         (let-location ((value c-pointer) (size unsigned-int))
     277           (%socket-option socket (socket-option->int option) value (location size))
     278           (let ((str (make-string size)))
     279             (move-memory! value str size)
     280             str)))
    279281       
    280282        ((memq option (alist-ref 'integer socket-options))
     
    294296          zmq-error 'socket-option (socket-pointer socket) option))
    295297
    296         ((memq option (alist-ref 'booelan socket-options))
     298        ((memq option (alist-ref 'boolean socket-options))
    297299         (let-location ((value bool) (size unsigned-int))
    298            (%socket-option socket option (location value) (location size))))
     300           (%socket-option socket (socket-option->int option) (location value) (location size))
     301           value))
    299302
    300303        (else
    301304         (error (format "socket option ~A is not retrievable" option)))))
     305
     306
     307(define (socket-fd socket)
     308  (let-location ((fd integer) (size unsigned-int))
     309    (%socket-option socket
     310                    (foreign-value "ZMQ_FD" int)
     311                    (location fd)
     312                    (location size))
     313    fd))
     314
    302315
    303316;; communication
Note: See TracChangeset for help on using the changeset viewer.