# Basic chat client using eventmachine (I AM A BIG NOOB)

**URL:** <https://www.ruby-forum.com/t/basic-chat-client-using-eventmachine-i-am-a-big-noob/193025>\
**Category:** Ruby\
**Created:** [August 10, 2010, 6:17am UTC](https://www.ruby-forum.com/t/basic-chat-client-using-eventmachine-i-am-a-big-noob/193025 "2010-08-10T06:17:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![angel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/49beb7/32.png) [@angel](https://www.ruby-forum.com/u/angel)\
**Post date:** [August 10, 2010, 6:17am UTC](https://www.ruby-forum.com/t/basic-chat-client-using-eventmachine-i-am-a-big-noob/193025/1 "2010-08-10T06:17:26Z")

</div>

Hi everybody, I’m try use eventmachine for make a simple chat client…I  
did the server and works fine but now I wanna do a client, the problem  
is simple, I’m very noob and I don’t know how send my data to server,  
actually I can receibe data using

def receive\_data(data)  
puts data  
end

but I don’t know how to send data…I’ve this

very simple  
module Client

def post\_init

send\_msje  
end

private  
def send\_msje  
while 1  
print "# say: "  
msje=gets  
puts “you say #{msje}”

```
  send_data msje
end

```

end

def receive\_data(data)  
puts data  
end  
end

EventMachine::run do  
EventMachine::connect “0.0.0.0”, 8081, Client  
end

is it good?..sorry I’m full noob and the few examples about clients  
using EM only send one data to server and close the conexion, I only did  
a ugly loop for keep the conexion, if someone can explain me a bit about  
this I appreciate it…

sorry for my english

---

<div class="post-metadata">

**Author:** ![angel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/49beb7/32.png) [@angel](https://www.ruby-forum.com/u/angel)\
**Post date:** [August 10, 2010, 9:16pm UTC](https://www.ruby-forum.com/t/basic-chat-client-using-eventmachine-i-am-a-big-noob/193025/2 "2010-08-10T21:16:45Z")

</div>

> is it good?..sorry I’m full noob and the few examples about clients  
> using EM only send one data to server and close the conexion, I only did  
> a ugly loop for keep the conexion, if someone can explain me a bit about  
> this I appreciate it…

If it works it’s good 🙂  
A few resources for you:  
[http://wiki.github.com/eventmachine/eventmachine/code-snippets](http://wiki.github.com/eventmachine/eventmachine/code-snippets)  
[http://groups.google.com/group/eventmachine](http://groups.google.com/group/eventmachine)
