internet上的html是基于UDP协议。
udp协议介绍
Internet协议集支持一个无连接的传输协议,该协议称为用户数据包协议(UDP,User Datagram Protocol)。UDP为应用程序提供了一种无需建立连接就可以发送封装的IP数据包的方法。
RFC 768描述了UDP。Internet的传输层有两个主要协议,互为补充。无连接的是UDP,它除了给应用程序发送数据包功能并允许它们在所需的层次上架构自己的协议之外,几乎没有做什么特别的事情。
面向连接的是TCP,该协议几乎做了所有的事情。
UDP协议与TCP协议一样用于处理数据包,在OSI模型中,两者都位于传输层,处于IP协议的上一层。UDP有不提供数据包分组、组装和不能对数据包进行排序的缺点,也就是说,当报文发送之后,是无法得知其是否安全完整到达的。
UDP用来支持那些需要在计算机之间传输数据的网络应用。包括网络视频会议系统在内的众多的客户/服务器模式的网络应用都需要使用UDP协议。
UDP协议从问世至今已经被使用了很多年,虽然其最初的光彩已经被一些类似协议所掩盖,但即使在今天UDP仍然不失为一项非常实用和可行的网络传输层协议。
目前还是不支持udp。想用udp,可以使用flash.UDP目前还未正式发布。
一个UDP的例子:
// This example shows a simple implementation of UPnP-SSDP M-SEARCH discovery using a multicast UDPSocket
var address = '239.255.255.250',
port = '1900',
serviceType = 'upnp:rootdevice',
rn = 'rn',
search = ''
// Create a new UDP client socket
var mySocket = new UDPSocket()
// Build an SSDP M-SEARCH multicast message
search += 'M-SEARCH * HTTP/1.1' + rn
search += 'ST: ' + serviceType + rn
search += 'MAN: "ssdp:discover"' + rn
search += 'HOST: ' + address + ':' + port + rn
search += 'MX: 10'
// Receive and log SSDP M-SEARCH response messages
function receiveMSearchResponses() { // While data in buffer, read and log UDP message
while (mySocket.readable.state === "readable") {
var msg = mySocket.readable.read()
console.log ('Remote address: ' + msg.remoteAddress +
' Remote port: ' + msg.remotePort +
'Message: ' + ab2str(msg.data))
// ArrayBuffer to string conversion could also be done by piping
// through a transform stream. To be updated when the Streams API
// specification has been stabilized on this point.
}
// Wait for SSDP M-SEARCH responses to arrive
mySocket.readable.wait().then(
receiveMSearchResponses,
e =>console.error("Receiving error: ", e)
)
}
// Join SSDP multicast group
mySocket.joinMulticast(address)
// Send SSDP M-SEARCH multicast message
mySocket.writeable.write(
{data : str2ab(search),
remoteAddress : address,
remotePort : port
}).then(
() =>{
// Data sent sucessfully, wait for response
console.log('M-SEARCH Sent')
receiveMSearchResponses()
},
e =>console.error("Sending error: ", e)
)
// Log result of UDP socket setup.
mySocket.opened.then(
() =>{
console.log("UDP socket created sucessfully")
},
e =>console.error("UDP socket setup failed due to error: ", e)
)
// Handle UDP socket closed, either as a result of the application
// calling mySocket.close() or an error causing the socket to be
closed.
mySocket.closed.then(
() =>{
console.log("Socket has been cleanly closed")
},
e =>console.error("Socket closed due to error: ", e)
)
相比UDP,TCP的示例代码显得简单一些
//
// This example shows a simple TCP echo client.
// The client will send "Hello World" to the server on port **9 and log
// what has been received from the server.
//
// Create a new TCP client socket and connect to remote host
var mySocket = new TCPSocket("127.0.0.1", **9)
// Send data to server
mySocket.writeable.write("Hello World").then(
() =>{
// Data sent sucessfully, wait for response
console.log("Data has been sent to server")
mySocket.readable.wait().then(
() =>{
// Data in buffer, read it
console.log("Data received from server:" + mySocket.readable.read())
// Close the TCP connection
mySocket.close()
},
e =>console.error("Receiving error: ", e)
)
},
e =>console.error("Sending error: ", e)
)
// Signal that we won't be writing any more and can close the write half of the connection.
mySocket.halfClose()
// Log result of TCP connection attempt.
mySocket.opened.then(
() =>{
console.log("TCP connection established sucessfully")
},
e =>console.error("TCP connection setup failed due to error: ", e)
)
// Handle TCP connection closed, either as a result of the application
// calling mySocket.close() or the other side closed the TCP
// connection or an error causing the TCP connection to be closed.
mySocket.closed.then(
() =>{
console.log("TCP socket has been cleanly closed")
},
e =>console.error("TCP socket closed due to error: ", e)
)
网络协议的一种. 用户数据报协议(UDP)UDP是使用IP协议在计算机数据交换时提供一定服务的通信协议。UDP是TCP的另外一种方法,象TCP一样,UDP使用IP协议来获得数据单元(叫做数据报),不象TCP的是,它不提供包(数据报)的分组和组装服务。
而且,它还不提供对包的排序,这意味着,程序程序必须自己确定信息是否完全地正确地到达目的地。如果网络程序要加快处理速度,那使用UPD就比TCP 要好。
TFTP就使用UDP而不使用TCP。UDP提供两种不由IP层提供的服务,它提供端口号来区别不同用户的请求,而且可以提供奇偶校验。在OSI模式中,UDP和TCP一样处于第四层,传输层。
UDP不是面向连接的,仅做简单的传输
UDP是TCP/IP的子协议,只要安装TCP/IP就可以了
下面的链接有详尽的图表介绍
http://www.cnpaf.net/Class/wlxy/0551120320849952683.htm