How to use sockets?
alex at tweedly.net
alex at tweedly.net
Thu Nov 18 16:04:52 EST 2004
Quoting Mark Wieder <mwieder at ahsoftware.net>:
> thierry-
>
> Thursday, November 18, 2004, 3:28:37 AM, you wrote:
>
> t> i've read in some technical books that Datagram is not a sure way
> t> to send information; means that some transport packets can be lost
> t> over the Net.
>
> t> Can someone tell me if it's still true on a single Win machine with
> t> 2 applications talking together with Datagram sockets ?
>
> t> or pointing some good information on this ?
>
> It's not an OS thing: TCP is one level up in the OSI network hierarchy
> from UDP.
Actually, UDP and TCP are at the same level in the hierarchy - each of them is
implemented directly on top of IP (along with ICMP, IGMP and various others).
TCP and UDP both provide a transport layer -
- TCP provides reliable, warranted (sometime called guaranteed, though that's
not strictly true) delivery, where the sequential arrival is guaranteed.
- UDP provides non-reliable (i.e. no "guarantee" of arrival),
non-sequential-guaranteed delivery.
> UDP Datagram packets are the lowest level in which you can
> package data and specify a recipient on the network, but there's no
> mechanism to define either a packet sequence or a handshake protocol.
> Both these things are in the TCP level. If you're comfortable with
> some packets possibly arriving out of order (you handle all this
> yourself) and are creating your own protocol for determining when
> packets have arrived safely then datagrams are *much* faster than TCP
> packets. If you're sending individual datagram packets rather than
> multi-packet transactions and do some simple handshaking then you're
> safe with datagrams. They're used quite a bit for control packets
> where small amounts of data need to be sent quickly.
>
> Do a web search for the OSI network model - here's a quick sample:
> http://www.webopedia.com/quick_ref/OSI_Layers.asp
>
> You'll find datagrams at layer 3 and TCP at layer 4.
>
> All you need to know about datagrams:
> http://www.faqs.org/rfcs/rfc768.html
>
If you are on a single machine, then (my opinion only)
- arrival out of order is theoretically possible - but so unlikely I'd
personally ignore it. (unless it happened as a side-effect of the non-arrival
test below).
- duplicated packet arrival is theoretically possible - but so unlikely I'd
ignore it
- non-arrival of a packet is also theroetically possible - I'd ignore it for an
application for my own personal use, but would not ignore it for a professional
app. However, a simple "packet lost - please retransmit" capability would be
enough to deal with the very, very small chance of it happening.
On Windows you should be able to install TCP/IP provideed there is at least one
interface capable of supporting it - needn't be Ethernet, modems can also
suport it, as can a loopback interface mentioned in other reponses.
-- Alex Tweedly.
More information about the use-livecode
mailing list