[usocket-devel] "experimental-udp" branch merged into usocket trunk

Chun Tian (binghe) binghe.lisp at gmail.com
Thu Jan 14 03:11:54 UTC 2010


Hi, Elliott

在 2010-1-14,10:02, Elliott Slaughter 写道:

> 
> It isn't clear to me how unconnected UDP sockets are to be used, since the host and port are unspecified. I would expect that most users would always want to use connected sockets.

To use a "unconnected" UDP socket, you can still use SOCKET-SEND and SOCKET-RECEIVE, however, since the sending target is not specified in the socket, you must use the keyword argument HOST and PORT each time you call SOCKET-SEND.

A "unconnected" UDP socket is very useful when you're trying to communicate with a lot of remote UDP servers but don't want or can't created correspond number of sockets.

> 
> [SOCKET-SEND]
> 
> Syntax: SOCKET-SEND usocket buffer length &key host port
> 
> SOCKET-SEND is used for sending packets through a UDP usocket, the "buffer" arguments usually need to be a vector of (unsigned-byte 8).
> 
> What does the return value of socket-send mean?

The return value of SOCKET-SEND is a integer which indicated how many bytes you actually send. In theory it should equal to the LENGTH argument in SOCKET-SEND, unless you're sending too much data.  Currently the return value when sending fails is not defined clearly, for some CLs "-1" will mean "sending fail", but I think I should change it to "NIL" instead in the future.

Considering UDP is unreliable, I suggest users never expect every packets could be sent successfully, however, a check on return value of SOCKET-SEND is usually necessary because it means some serious mistake is happening (i.e. no network), not that packets are dropped on their way.

The constant +max-datagram-packet-size+ is defined in usocket.lisp, line 14:

 (defconstant +max-datagram-packet-size+ 65536)

I didn't export the symbol +MAX-DATAGRAM-PACKET-SIZE+ because it's a constant and hard limit of UDP implementation. Users don't need to change it's value, instead, there're extra keyword arguments in API functions when user want to set maximum packet sizes.

--binghe

> 
> Thanks for working on this. I'm eagerly awaiting full compatibility win32 implementations.
> 
> -- 
> Elliott Slaughter
> 
> "Don't worry about what anybody else is going to do. The best way to predict the future is to invent it." - Alan Kay

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2603 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/usocket-devel/attachments/20100114/46c29467/attachment.bin>


More information about the usocket-devel mailing list