1
我寫了一個Ruby腳本來連接和登錄IRC服務器,但是當IRC服務器發出一條新消息時,套接字不會收到它,例如日誌是:紅寶石套接字沒有收到所有消息
:irc.someserver.net NOTICE Auth :*** Looking up your hostname...
:irc.someserver.net NOTICE Auth :Welcome to someserver Net!
:irc.someserver.net 003 brobot :This server was created 15:40:35 Mar 28 2012
:irc.someserver.net 005 brobot MAXTARGETS=20 MODES=20 NETWORK=Studio NICKLEN=32 Net PREFIX=(ov)@+ [email protected]+ TOPICLEN=308 VBANLIST WALLCHOPS WALLVOICES :are supported by this server
:irc.someserver.net 372 brobot :- Welcome To the someserver Chat Server. Please Select the #Team Channel.
:irc.someserver.net 252 brobot 1 :operator(s) online
:irc.someserver.net 265 brobot :Current Local Users: 5 Max: 5
:irc.someserver.net 353 brobot = #brobot_dev :@Pablo brobot
:[email protected] PRIVMSG #brobot_dev :f
PING :irc.someserver.net
這是一個示例日誌,它看起來不錯,但:[email protected] PRIVMSG #brobot_dev :f
是當它錯過的消息。比如我送5個消息和客戶端只接收1。這是客戶端代碼:
require 'socket' # Sockets are in standard library
hostname = '10.1.1.1'
port = 6667
server = TCPSocket.open(hostname, port)
loop {
server.flush
puts server.gets.chomp
if server.gets.chomp =~ /:.*NOTICE Auth :\*\*\* Found your hostname/
server.puts "USER brobot brobot brobot brobot\r\nNICK brobot\r\n"
elsif server.gets.chomp =~ /:\S* 26*/
server.puts "JOIN #brobot_dev\r\n"
end
}
我做錯了嗎?謝謝!