PageRenderTime 46ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/ext/socket/sagittarius/socket.scm

https://code.google.com/p/sagittarius-scheme/
Scheme | 91 lines | 59 code | 2 blank | 30 comment | 0 complexity | 0d4be7f869e87b9106e41e329b43a15d MD5 | raw file
Possible License(s): BSD-2-Clause
  1. ;;; -*- Scheme -*-
  2. ;;;
  3. ;;; socket.scm - socket library
  4. ;;;
  5. ;;; Copyright (c) 2000-2011 Takashi Kato <ktakashi@ymail.com>
  6. ;;;
  7. ;;; Redistribution and use in source and binary forms, with or without
  8. ;;; modification, are permitted provided that the following conditions
  9. ;;; are met:
  10. ;;;
  11. ;;; 1. Redistributions of source code must retain the above copyright
  12. ;;; notice, this list of conditions and the following disclaimer.
  13. ;;;
  14. ;;; 2. Redistributions in binary form must reproduce the above copyright
  15. ;;; notice, this list of conditions and the following disclaimer in the
  16. ;;; documentation and/or other materials provided with the distribution.
  17. ;;;
  18. ;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19. ;;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20. ;;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  21. ;;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  22. ;;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  23. ;;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
  24. ;;; TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  25. ;;; PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  26. ;;; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  27. ;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  28. ;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. ;;;
  30. (load-dynamic-library "sagittarius--socket")
  31. (library (sagittarius socket)
  32. (export make-client-socket
  33. make-server-socket
  34. call-with-socket
  35. shutdown-output-port
  36. socket?
  37. make-socket
  38. socket-port
  39. socket-accept
  40. socket-send
  41. socket-recv
  42. socket-shutdown
  43. socket-close
  44. AF_UNSPEC
  45. AF_INET
  46. AF_INET6
  47. SOCK_STREAM
  48. SOCK_DGRAM
  49. SOCK_RAW
  50. SOCK_RDM
  51. SOCK_SEQPACKET
  52. AI_PASSIVE
  53. AI_CANONNAME
  54. AI_NUMERICHOST
  55. AI_V4MAPPED
  56. AI_ALL
  57. AI_ADDRCONFIG
  58. SHUT_RD
  59. SHUT_WR
  60. SHUT_RDWR
  61. MSG_OOB
  62. MSG_PEEK
  63. MSG_DONTROUTE
  64. MSG_CTRUNC
  65. MSG_PROBE
  66. MSG_TRUNC
  67. MSG_DONTWAIT
  68. MSG_EOR
  69. MSG_WAITALL
  70. MSG_FIN
  71. MSG_SYN
  72. MSG_CONFIRM
  73. MSG_RST
  74. MSG_ERRQUEUE
  75. MSG_NOSIGNAL
  76. MSG_MORE
  77. MSG_EOF
  78. ;; clos
  79. <socket>
  80. )
  81. (import (core)
  82. (sagittarius)
  83. (sagittarius socket impl))
  84. (define call-with-socket
  85. (lambda (socket proc)
  86. (receive args (proc socket)
  87. (socket-close socket)
  88. (apply values args))))
  89. )