Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8885065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:13:04+00:00 2026-06-14T21:13:04+00:00

I want to send a string from a client to a server via socket.

  • 0

I want to send a string from a client to a server via socket. I tried doing this three ways (write, puts and print)

hostname = 'localhost'
port = 3000
s = TCPSocket.new(hostname, port)

s.write("hello")
s.puts("hello")
s.print("hello")

s.close

but it gives me an error (the error does not appear on the browser but on the terminal):
ERROR bad Request-Line 'hello'.

Is it possible to send strings from the client to the server or is it only from server to client?

I am using Ruby 1.8.7 and Rails 3.0.1

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T21:13:05+00:00Added an answer on June 14, 2026 at 9:13 pm

    It looks like the server doesn’t like your Hello line. You mention Ruby and Rails, I guess you want to talk to WEBrick HTTP server – why don’t you speak HTTP then?

    If you want to implement HTTP client, take a look at http://www.tutorialspoint.com/ruby/ruby_socket_programming.htm

    Under A Tiny Web Browser section you’ll find a working HTTP client using TCPSocket, as well as Net::HTTP example.

    If HTTP is what you need, Net::HTTP is the way to go, implementing HTTP sounds like reinventing the wheel.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to send secure data(strings) from a client to a server. This is
I want to send XMPP message from my android client to GAE Server using
i want to send a file from client to server. My code: Client side
I have a TCP socket client-server program in Java. From the client, I send
I want to send String from C# to Jave I do it in C#
Well I want to send commands and data between client and server. I have
I have server and client to send/receive a string through windows sockets. Client code
I want to send a couple of values to a web server from my
I have a client and server program where I want to send an entire
I want to send a byte array from a web service to a client

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.