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
分享到:
相关推荐
移动格子势中稳定的物质波包,海文华,李泽军,考虑一个由移动格子势驱动的玻色-爱因斯坦凝聚体,导出一维Gross-Pitaevskii方程精确的行波解,它满足光学势和原子相互作用之间的平衡�
trasnfering data using the udp packets, the concept in networking
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 ...
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 ...
user: ‘root’ host: `localhost’ (Got timeout reading communication packets) MYSQL server has gone away 引起这个原因是不可怕的.原因是更改了系统的断开时间. mysql>show gloable variables like “%time...
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 ...
Wireshark- A Guide to Color My Packets
Three-dimensionallocalized Airy-Laguerre-Gaussian wave packets in free space
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 ...
Route Packets, Not Wires On-Chip Interconnection Networks
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 ...
path of packets in linux kernel. The paper give exhausive description about how udp/tcp packets passes in the linux kernel.
1. In both parts of Fig. 6-6, there is a comment that the value of SERVERPORT mu
A java wrapper for popular "libpcap" and "WinPcap" libraries. Accurate full API translation.... Send custom packets, gather statistics. Comprehensive and easily extensible DPI engine.
Nmap, or Network Mapper, is a free, open source tool that is available under the GNU General Public License as published by the Free Software ...and send packets with bogus TCP or UDP checksums.
北大POJ1017-Packets 解题报告+AC代码
than ICMP/UDP packets that the usual implementations use, thus bypassing gateways that block traditional traceroute packets. In addition to providing the functionality of the standard traceroute ...
The present document specifies the structure of the Secured Packets in a general format and in implementations using Short Message Service Point to Point (SMS-PP) and Short Message Service Cell ...
--count NUM Number of packets to send. --help This help text. --port XX Port to which connection attempt is made. Default is 80. --proto XX Protocol to use. Options include tcp, icmp, udp, stream,...