Socket Server:
# -*- coding: cp936 -*-
"""
广播服务器,接收来自广播的消息,并进行应答
设置socket选项:SO_BROADCAST
"""
import socket
host = ""
port = 50000
s = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
s.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1)
s.setsockopt(socket.SOL_SOCKET,socket.SO_BROADCAST,1)
s.bind((host,port))
while 1:
message,address = s.recvfrom(8192)
print "Got data from",address
s.sendto("I am here",address)
Socket Client:
# -*- coding: cp936 -*-
"""
对socket进行广播,使用地址<broadcast>,LAN中的所有机器会收到此消息
此客户端收到应答消息后退出.
"""
import socket,sys
dest = ("<broadcast>",50000)
s = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
s.setsockopt(socket.SOL_SOCKET,socket.SO_BROADCAST,1)
s.sendto("Hello",dest)
while 1:
(buf,address) = s.recvfrom(2048)
if not len(buf):
break
print "received from %s:%s" % (address,buf)
See http://blog.chinaunix.net/u/19742/showart_411039.html
分享到:
相关推荐
这个是我写的linux下udp广播和接受的例子。 记住:在linux下一定要关闭sexlinux和防火墙! 或者 在防火墙里设置允许udp中相应的端口,允许通信!
abstract: We consider the problem of broadcasting in an ad hoc wireless network, where all nodes of the network are sources that want to transmit information to all other nodes. Our figure of merit is...
标题中的“TS_UDP_PCR控制发送速率”是一个与数字视频广播(Digital Video Broadcasting, DVB)和网络传输相关的技术主题。在这个场景下,“TS”通常指的是传输流(Transport Stream),这是DVB标准中用于传输多媒体...
Digital Video and Audio Broadcasting Technology
Digital Video and Audio Broadcasting Technology A Practical Engineering Guide” deals with all the most important digital television, sound radio and multimedia standards such as MPEG, DVB, DVD, DAB, ...
DVB Specification - DVB specification for data broadcasting
在C#编程中,可以使用PBD(Peer-to-Peer Broadcasting)库来实现UDP打洞。PBD提供了一套API,使得开发者能够轻松地创建支持NAT穿透的P2P应用。以下是关于这个技术的一些关键知识点: 1. **UDP协议**:UDP(User ...
Sparse passive radar imaging based on digital video broadcasting satellites using the MUSIC algorithm
The Digital Video Broadcasting Project (DVB) is an industry-led consortium of over 300 broadcasters, manufacturers, network operators, software developers, regulatory bodies and others in over 40 ...
SAP BI Information Broadcasting Introduction
在描述中提到的Linux下服务器端视频采集,这通常涉及到视频捕获硬件接口的访问,如V4L2(Video for Linux Two)或DVB(Digital Video Broadcasting)APIs。这些接口允许开发者读取来自摄像头或其他视频源的数据,并...
sophisticated broadcasting functions basic linear algebra functions basic Fourier transforms sophisticated random number capabilities tools for integrating Fortran code. tools for integrating C/...
广播电视行业术语 Glossary of Broadcasting
Digital Audio Broadcasting (DAB) ,非常难得的TDMB 标准,Digital Audio Broadcasting (DAB) ,非常难得的TDMB 标准,Digital Audio Broadcasting (DAB) ,非常难得的TDMB 标准,非常难得
精彩并且全面的介绍的数字电视广播技术的各方面关键技术。包括mpeg ts传输流的详细分析和介绍,mpeg2的编解码,数字音频技术等等。
in Terrestrial Digital Multimedia Broadcasting (T-DMB) system using depth-image-based rendering (DIBR). The 2D/3D mixed service is the 3D service type that 3D contents are shown partially while a 2D ...
Broadcasting Intents Summary Chapter 14 App Widgets Using Content Providers Through Widgets Summary Chapter 15 Networking and Web Overview Quick Example Networking Basics HTTP API Apache HTTP Client ...
在本文中,我们将深入探讨Laravel开发中的一个特殊话题——`l5-scaledrone-broadcasting-driver`。这个驱动程序是Laravel广播功能的一个扩展,它允许开发者将实时消息通过Scaledrone服务推送到Web客户端。Laravel是...
讲解讲解关于FTN在卫星广播通信方面的文章,费了好大力气才获取到全文,研究FTN和DVB-S的同学可以看一下