How to create a web chat system using ruby ​​Gserver

I am trying to create a web chat system and I am going to the ruby ​​gserver user. I reviewed this example . However, my question is when I get user input from the Internet, and in the controller I have user input. Now, as the client connects to the server, to pass this custom input value to the server.

The server after receiving the value will populate the database. Thus, the client will perform all read operations from the database. However, I was wondering how the client will connect to the server. This is a simple question, but I could not understand.

+2
ruby chat
source share
1 answer

Now I am making some massive assumptions because your question is as vague as hell.

Assumption 1: you are using a largely unmodified chat server
Assumption 2: you are using the web service and chat server on the same host

In this case, you can connect to the chat server using libs sockets and send it this way.

require 'socket' include Socket::Constants socket = Socket.new( AF_INET, SOCK_STREAM, 0 ) sockaddr = Socket.pack_sockaddr_in( 1234, 'localhost' ) socket.connect( sockaddr ) socket.write( "foo\nquit\n" ) puts socket.read socket.close 

This will send "foo" to the chat server and then close the connection

+1
source share

All Articles