http://snippets.dzone.com/posts/show/4541
http://www.rubyinside.com/create-a-daemon-server-in-11-lines-of-ruby-58.html
require 'socket'
UDP_RECV_TIMEOUT = 3
def q2cmd(server_addr, server_port, cmd_str)
resp, sock = nil, nil
begin
cmd = "\377\377\377\377#{cmd_str}\0"
sock = UDPSocket.open
sock.send(cmd, 0, server_addr, server_port)
resp = if select([sock], nil, nil, UDP_RECV_TIMEOUT)
sock.recvfrom(65536)
end
if resp
resp[0] = resp[0][4..-1]
end
rescue IOError, SystemCallError
ensure
sock.close if sock
end
resp ? resp[0] : nil
end
server = "tastyspleen.net"
port = 27912
cmd = "status"
result = q2cmd(server, port, cmd)
puts result
分享到:
相关推荐
本教程主要介绍了如何使用Simulink建立UDP Send模型和UDP Receive模型,并且如何在veristand工程中添加UDP-Custom-Device来实现通讯。 一、Prescan Simulink UDP 模型建立 在prescan工程中,我们需要建立一个...
标题“Stable matter-wave packets in a traveling lattice potential”中提到的“稳定物质波包”和“移动格子势”涉及量子物理领域中的玻色-爱因斯坦凝聚体(Bose-Einstein Condensate,简称BEC)的概念。...
UDPTunnel is a small program which can tunnel UDP packets bi-directionally over a TCP connection. Its primary purpose (and original motivation) is to allow multi-media conferences to traverse a ...
It sends out UDP packets to the specfied IP and port at a controllable rate. Packets can be made from a typed text string, a given number of random bytes or data from a file. Useful for server ...
Display filters in Wireshark are used to filter the packets displayed in the packet list. They can be simple or complex, depending on the level of detail required. For example, you can filter packets ...
描述 "trasnfering data using the udp packets, the concept in networking" 强调了我们将深入理解通过UDP数据报进行网络通信的概念。在TCP/IP模型中,数据报是UDP协议的基本单位,它们不保证顺序到达或重传,因此...
6. Server_send.vi:这可能是一个服务器端的LabVIEW虚拟仪器,负责发送UDP数据包。它可能包含初始化UDP套接字、设置发包参数、打包数据以及发送等功能。 7. Receiver.vi:这个可能是客户端的LabVIEW虚拟仪器,负责...
从输出结果中可以看到,Udp protocol 的统计信息,包括 packets received、packets to unknown port received、packet receive errors 等。从这些信息中可以看到,协议栈处理中 UDP 有丢包,错误原因是由于接收缓冲...
- **Connectionless Protocol (UDP):** UDP (User Datagram Protocol) is a connectionless protocol that does not guarantee delivery or order of packets. It does not establish a dedicated connection ...
user: ‘root’ host: `localhost’ (Got timeout reading communication packets) MYSQL server has gone away 引起这个原因是不可怕的.原因是更改了系统的断开时间. mysql>show gloable variables like “%time...
【fuzzy-packets】是一个基于C++开发的网络通信工具,专用于利用数据包和UDP套接字进行网络通信。这个项目使用了SDL_Net库,这是一个轻量级且易于使用的网络API,由著名的游戏开发库SDL(Simple DirectMedia Layer)...
"How-to-craft-UDP-packets-and-send-them-with-WinPCa.pdf"这篇文档可能提供了更详细的实现细节,而"RawPacket.zip"可能包含示例代码或其他辅助资源。通过实践和学习这些资料,你将能更深入地理解和掌握这一技术。
Java Netflow Collect/Analyzer uses pure Java to collect netflow v1 v5 v7 v8 v9 UDP packets from cisco routers. It stores both raw data or analyzed contents to DB thru JDBC and can be used in large ...
This paper presents a new packet routing scheme which allows a vehicle to discover the existence of a gateway to the Internet and to send/receive packets to/from the gateway via multihop ...
3. **UDP的存在理由**:UDP(用户数据报协议)存在的原因主要有两个:(1) UDP是无连接的,不需要预先建立连接,因此减少了延迟,适合实时通信如视频会议、在线游戏等。(2) UDP提供了端口号机制,使得服务端可以区分...
hping2 is a network tool able to send custom ICMP/UDP/TCP packets and to display target replies like ping do with ICMP replies. hping2 handle fragmentation, arbitrary packet body and size and can ...
For these packets, it is inefficient to follow the conventional medium access control (MAC) protocols because they lead to poor utilization of service resources. We propose a ...
标题与描述:“Route Packets, Not Wires:On-Chip Interconnection Networks” 此标题与描述主要探讨了在芯片设计中采用网络互连而非传统布线技术的概念。文章由斯坦福大学计算机系统实验室的William J. Dally和...
path of packets in linux kernel. The paper give exhausive description about how udp/tcp packets passes in the linux kernel.
SCDP,全称为“Send CDP Packets”,是一款开源软件工具,主要功能是通过选定的网络接口发送Cisco Discovery Protocol(CDP)数据包。CDP是Cisco Systems开发的一种网络协议,用于在网络设备之间进行邻接发现和信息...