Additional USOCKET API changes beside SOCKET-RECEIVE and SOCKET-SEND:
1. Add a new keyword argument to SOCKET-CONNECT: (PROTOCOL :TCP). When giving (:PROTOCOL :UDP) to SOCKET-CONNECT, this function should return a DATAGRAM-USOCKET
There're two cases when PROTOCOL is :UDP
* (and HOST PORT), do a connect() as additional to socket(), * (not (and HOST PORT), only call socket().
2. Add a new function: SOCKET-SYNC as high-level UDP message send/recv function, which can support packet retransmit and auto-learnt timeout value.
3. Add a new function: SOCKET-SERVER to create a simple UDP server.
I think above changes will not effect exist applications which don't know UDP.
--binghe
When looking at usocket.lisp, you'll find there is a datagram-usocket class commented out. I think this class (even without any additional slot definitions) should be used for UDP sockets.
Then there's datagram-usocket-p, which should start returning T when the passed in object is a true descendant of DATAGRAM-USOCKET.
Looking further, you'll find there are functions defined for creating stream and stream-server objects. A function like that should be created for UDP sockets.
I think it's only sane to extend WAIT-FOR-INPUT to apply to UDP sockets as well as any of the currently supported sockets. The LispWorks variant of this function (for win32) is still on my laptop. I'll try to finish it up soon, so that you can all start testing it.
I propose we implement recv()/recvfrom() as one function: SOCKET-RECEIVE. I think we shouldn't bother implementing recv() and recvfrom() as separate interfaces: I think we should return the recvfrom-address field as the second return value of SOCKET-RECEIVE.
I also propose we implement send()/sendto() as one function: SOCKET-SEND. I think we should provide the sendto address as an optional parameter to the SOCKET-SEND function.
Also, I think the function should check for connected-ness of the datagram socket. If the sendto address is specified on a connected socket AND the address specified is unequal to the connected address, the function should error.
Oh. One last thing: local and peer address retrieval functions should be adapted to apply to UDP sockets as well as the currently supported stream sockets.
I hope this is all a bit clear! If you have (m)any questions, please don't hesitate to ask.
Bye,
Erik.