# Simple socketing

**URL:** <https://www.ruby-forum.com/t/simple-socketing/98186>\
**Category:** Ruby\
**Created:** [July 12, 2006, 11:30pm UTC](https://www.ruby-forum.com/t/simple-socketing/98186 "2006-07-12T23:30:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![canute](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/7ba0ec/32.png) [@canute](https://www.ruby-forum.com/u/canute)\
**Post date:** [July 12, 2006, 11:30pm UTC](https://www.ruby-forum.com/t/simple-socketing/98186/1 "2006-07-12T23:30:59Z")

</div>

Hi there, I recently started with Ruby and I am trying to make a very  
simple irc bot, but I am having some slight problems though.

This is what I came up with:

require ‘socket’  
class Irc  
def connect(server, port = 6667)  
@socket = TCPsocket.new(server, port)  
end  
def to\_server(text)  
@socket.gets(text)  
return true  
end  
def from\_server()  
return @socket.puts  
end  
end  
irc = Irc.new  
irc.connect(“irc.homelien.no”, 6667)  
irc.to\_server(‘NICK: testbot’)  
irc.to\_server(‘USER: testbot “” “[irc.efnet.net](http://irc.efnet.net)” :testbot’)  
go = true  
while go == true  
if (text = irc.from\_server)  
puts(text)  
end  
end
