Lisp HUG Maillist Archive

When will LispWork has UDP support?

Hi, LispWorks

It's strange that LispWorks doesn't have UDP networking support, it's as
important as TCP, as least I think. It seems that Allegro CL has full
UDP support, so does SBCL, and OpenMCL.

The IOlib[1] project can be used for portable networking on many UNIX
platform, but this project cannot used on win32.

So, does anyone have experience on UDP networking using LispWorks
Windows Edition? Am I must call win32 API directly?

Thanks.

Chun Tian (binghe)


Re: When will LispWork has UDP support?

Chun Tian (binghe) wrote:
> Hi, LispWorks
>
> It's strange that LispWorks doesn't have UDP networking support, it's as
> important as TCP, as least I think. It seems that Allegro CL has full
> UDP support, so does SBCL, and OpenMCL.
>
> The IOlib[1] project can be used for portable networking on many UNIX
> platform, but this project cannot used on win32.
>
> So, does anyone have experience on UDP networking using LispWorks
> Windows Edition? Am I must call win32 API directly?
>
> Thanks.
>
> Chun Tian (binghe)
>
>
>   
OK, since still no official answer, I'll do this myself.

Now I'm working on a UDP support of LispWorks, I find LispWorks' comm
package already has many BSD socket functions base on FLI, and I'm
planing to use some of them:

(:STRUCT COMM::SOCKADDR_IN)
COMM::INITIALIZE-SOCKADDR_IN
(INITIALIZE-SOCKADDR_IN INADDR FAMILY HOST SERVICE PROTOCOL)
COMM::*SOCKET_SOCK_STREAM*
COMM::*SOCKET_PF_UNSPEC*
COMM::SOCKET
COMM::BIND
COMM::*SOCKOPT_TCP_NODELAY*
COMM::*SOCKOPT_IPPROTO_TCP*
COMM::SETSOCKOPT
SYSTEM::GET-OS-ERROR-STRING
COMM::SET-SOCKET-NO-BLOCKING
(:STRUCT COMM::SOCKADDR)
COMM::CONNECT
COMM::CLOSE-SOCKET
COMM::WAIT-FOR-CONNECT-TO-COMPLETE
COMM::GETHOSTBYNAME
COMM::INET_ADDR
(:STRUCT COMM:IN_ADDR)
COMM::HTONL
COMM::GET-PORT-FOR-SERVICE
comm::*socket_af_inet*
comm::*socket_sock_stream* (need comm::*socket_sock_dgram*)
COMM::FCNTL

And below are some code I wrote:

(in-package :comm)

(defconstant *socket_pf_inet* 2 "IP protocol family")
(defconstant *socket_sock_dgram* 2
  "Connectionless, unreliable datagrams of fixed maximum length.")

(defclass socket-datagram (socket-stream)
  ()
  (:documentation "UDP Socket"))

(defun open-udp-datagram (hostname
                          service
                          &key
                          (direction :io)
                          (element-type 'base-char)
                          errorp
                          read-timeout
                          write-timeout
                          timeout
                          local-address
                          local-port)
  "learn from open-tcp-stream"
  (let ((socket (connect-to-udp-server hostname service
                                       :errorp errorp
                                       :timeout timeout
                                       :local-address local-address
                                       :local-port local-port)))
    (unwind-protect
        (make-instance 'socket-datagram
                       :init t
                       :socket socket
                       :direction direction
                       :element-type element-type
                       :read-timeout read-timeout
                       :write-timeout write-timeout)
      (close-socket socket))))

I think a UDP interface based on LispWorks' already exist TCP and
socket-stream is quite possible. With help from people, I have runnable
(but not OO based) win32/unix UDP support based on LispWorks' FLI. I
think I can merge them into my initial work.

Wish me good luck, please:)

Chun Tian (binghe)
(A person who want to run his SNMP implementation on LispWorks)


Updated at: 2020-12-10 08:45 UTC