UDP (datagram) socket usage.

Dar Scott dsc at swcp.com
Sun Dec 26 22:07:09 EST 2004


On Dec 26, 2004, at 7:40 PM, Alex Tweedly wrote:

>> The server knows the port on the other end (pRemote, in your 
>> example).  Simply reply to that.
>
> Sorry, but I don't get it.
>
> The server can reply to pRemote easily - but how does the client 
> receive that packet ?
> The client doesn't know the port number that appeared in pRemote, so 
> he doesn't know the values he needs for an "accept".

Sorry about that.  I was confused about this originally, too.  The docs 
don't help.  And it being unlike the TCP comm, confuses it, too.

When you 'open datagram socket', specify a callback.  The callback is 
NOT for completion of the open.  That completes immediately.  It is for 
the incoming packets, the responses.

The slight minus is that there is no way to squelch input.  The big 
plus is that you don't loose data.

Some UDP client-server transactions are short-lived.  The server sends 
one datagram back and closes.  The client receives one one response 
datagram and closes.  (If this doesn't fit your model, we can get more 
into it.)

Dar

**********************************************
     DSC (Dar Scott Consulting & Dar's Lab)
     http://www.swcp.com/dsc/
     Programming Services and Software
**********************************************



More information about the use-livecode mailing list