Ruby and C network interaction



Hi,

I'm working on a small client/server application in my spare time,
using C and win32 for the client and Ruby for the server. I'm having
an interaction issue and was wondering if anyone could help. I'm not
an expert in Ruby or networking :\

Anyway, on the client side I set up a socket and connect to the server,
then send a username with:

send (socket, myMessage, sizeof (myMessage))

Which works fine. The Ruby server receives and prints it with:

username = session.recv(20).strip
puts "Username: '#{username}'"

(session is an instance of TCPServer)

A password is sent the same way. My trouble occurs when I try to send
data back to the client from the server.

The client tries to receive with:

recv (socket, sockMsg, sizeof(sockMsg), 0);

And the server sends with:

sent = session.send("success", 0)
puts "#{sent} characters sent"

The server outputs "7 characters sent", but I don't receive anything on
the client side. I output the contents of sockMsg, and it's empty.

Server code is here (It's not much, just something simple):
http://www.craighammell.com/code/server.rb

Any help would be appreciated.

Thanks.

.



Relevant Pages

  • Re: Socket switch delay
    ... both at the client and at the server (and why ... would you set the send buffer size to zero on a non-overlapped ... One glaring error is your client does ... So when you use a single socket, ...
    (microsoft.public.win32.programmer.networks)
  • Re: Locking on async calls
    ... you must synchronize the entire SendMessage routine as an atomic ... operation to prevent mixed messages from being transmitted to the server. ... You are correct that read and write on the socket do not interfere with each ... If you want to handle multiple client connections from one server object ...
    (microsoft.public.dotnet.general)
  • Re: Design issue with WinSock/GetQueuedCompletionStatus
    ... delegate that to a shutdown routine called after all worker threads ... The application I've created is a server accepting connections on a few ... different TCP/IP ports and then lets the client run different commands. ... a TCP/IP socket can be closed for 2 different reasons: ...
    (microsoft.public.win32.programmer.networks)
  • Re: socket communication: socket doesnt connect
    ... Microsoft MVP, MCSD ... As far as your server code goes, ... accept the listening socket. ... Client client = new Client; ...
    (microsoft.public.vc.language)
  • Re: TCP server stop receiving new connections
    ... reset the event mask of your listening socket each time you ... I have a strange problem in my class library used by all our client ... server applications. ... incomming connections, but keeps current connections. ...
    (microsoft.public.win32.programmer.networks)