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 8178329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:44:13+00:00 2026-06-06T23:44:13+00:00

I wonder why I can’t YAML load right after YAML dump I tried following

  • 0

I wonder why I can’t YAML load right after YAML dump

I tried following code, but there is no “end” printing on console

could someone tell me what’s wrong with me?

thanking you

server side ruby code

require 'socket'
require 'yaml'
h = []
s = TCPServer.open('localhost',2200)
c = s.accept
loop do
    YAML.dump(h,c)
    YAML.load(c)
    puts "end"
end

client side ruby code

require 'socket'
require 'yaml'
d = []
s = TCPSocket.open('localhost',2200)
loop do
    d = YAML.load(s)
    YAML.dump("client",s)
    puts "end"
end
  • 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-06T23:44:15+00:00Added an answer on June 6, 2026 at 11:44 pm

    YAML doesn’t know in advance how many bytes to read, so it tries to read as much as possible and waits forever. There is no end_of_record for TCP/IP.

    require 'socket'
    require 'yaml'
    h = []
    s = TCPServer.open('localhost',2200)
    c = s.accept
    loop do
        s = YAML.dump(h)
        c.write([s.length].pack("I"))
        c.write(s)
        length = c.read(4).unpack("I")[0]
        p YAML.load(c.read(length))
    end
    
    
    
    require 'socket'
    require 'yaml'
    d = []
    c = TCPSocket.open('localhost',2200)
    loop do
        length = c.read(4).unpack("I")[0]
        p YAML.load(c.read(length))
        s = YAML.dump("client")
        c.write([s.length].pack("I"))
        c.write(s)
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wonder how can I code this: //if there is any ajax request $("#loader").css("display","block");
I wonder how can I search for a certain pattern in file, but only
wonder whether someone can help me with the following one... I have a struct
I wonder if anyone can point me in the right direction I'm fairly new
I wonder how can I load animated gif to picturebox and than delete original
I wonder how can i accomplish the following: I would like to display the
Possible Duplicate: Operator overloading I was wonder how can I over load the Conditional
I wonder how can I reconcile the following error? JVM cannot use large page
Sorry for beginner's questions but I wonder how can I set the root servlet
Please can you help me with advice or demo code for the following task:

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.