Some questions about sockets

O

Omar Campos

Hi all,

I am practicing socket programming in Ruby, and I have some questions.
Hopefully someone here might be able to clarify them for me:

1. Must a connection always be from a TCPServer to a TCPSocket? Can
there be a TCPSocket - TCPSocket connection?

2. What are the possible values to the second argument of
TCPSocket#send? The Ruby Book included with the one click installer
says the possible values can be found in page 478, but it's a little
hard to find page 478 inside a .chm file!

3. Must the first argument to TCPSocket#send always end with "\n" for
TCPServer to recieve it?

Thanks for any info!
 
R

Reid Thompson

Omar said:
Hi all,

I am practicing socket programming in Ruby, and I have some questions.
Hopefully someone here might be able to clarify them for me:

1. Must a connection always be from a TCPServer to a TCPSocket? Can
there be a TCPSocket - TCPSocket connection?

2. What are the possible values to the second argument of
TCPSocket#send? The Ruby Book included with the one click installer
says the possible values can be found in page 478, but it's a little
hard to find page 478 inside a .chm file!

They are listed in the Constants section of class Socket
Send/receive options:

MSG_DONTROUTE, MSG_OOB, MSG_PEEK.
 
P

Philliam Auriemma

3. Must the first argument to TCPSocket#send always end with "\n"  for
TCPServer to recieve it?

I think that the \n flushes the buffer or something. So if you do
something like TCPSocket.send("fefefe", 0); TCPSocket.flush then it
should work.
Alternatively, I believe TCPSocket.puts("message") works without
needing
a \n.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
474,262
Messages
2,571,056
Members
48,769
Latest member
Clifft

Latest Threads

Top