[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

TCP/IP in Ruby

BCoish

11/26/2003 5:54:00 PM

All:

I've run into a problem that I'm hoping is not unique.
I am learning TCP/IP programming in Ruby and the
following code generates a strange result:


# CLIENT.RB
# =========
require 'socket'
s=TCPSocket.new("localhost", ARGV[0])
s.write("test\n")
puts s.gets
# 2nd read required to retrieve
# modified string from server.
# puts s.gets

s.close

# SERVER.RB
# =========
require "socket"
gs = TCPserver.open(0)
printf("server is on port %d\n", gs.addr[1])
s=gs.accept
puts s.gets
s.write(s.gets.upcase)
s.close


The preceeding code is used to run a server that accepts a
single client. The client sends the server a string, the
server reads and converts the string to uppercase and then
sends it back to the client.

That's how it's supposed to work and on the PC it does work.
However, on OpenVMS the client requires two, consecutive reads
in order to get the uppercased value from the server (i.e. first
read returns the original string "test"; second read returns the
modified string sent back by the server "TEST"). This leads me
to believe it's an internal buffer problem. Before I speculate
further I wanted to ask if anyone has come across this before and
what may be the cause of it.

Regards,
Brad
BCoish@Dymaxion.com
17 Answers

jjh-ruby-talk

11/26/2003 7:17:00 PM

0

>>>>> "BCoish" == BCoish <BCoish@Dymaxion.ca> writes:

BCoish> I've run into a problem that I'm hoping is not unique. I am
BCoish> learning TCP/IP programming in Ruby and the following code
BCoish> generates a strange result:

The original code doesn't work on a Linux machine either. Here's
slightly altered code that probably will do what you want.

[jeremyhi@rapier ruby]$ cat client.rb
# CLIENT.RB
# =========
require 'socket'
s=TCPSocket.new("localhost", ARGV[0])
s.write("test\n")
puts s.gets
s.close()
[jeremyhi@rapier ruby]$


Change server.rb to only read from the client 1 time.

[jeremyhi@rapier ruby]$ cat server.rb
# SERVER.RB
# =========
require "socket"
gs = TCPserver.open(0)
printf("server is on port %d\n", gs.addr[1])
s = gs.accept
line = s.gets
puts line
s.write(line.upcase)
s.close

BCoish> The preceeding code is used to run a server that accepts a
BCoish> single client. The client sends the server a string, the server
BCoish> reads and converts the string to uppercase and then sends it
BCoish> back to the client.

The server as originally written reads from the client twice, once for
each 'gets'. Since the client is only writing once to the server this
is probably the underlying issue.

BCoish> That's how it's supposed to work and on the PC it does work.
BCoish> However, on OpenVMS the client requires two, consecutive reads
BCoish> in order to get the uppercased value from the server (i.e. first
BCoish> read returns the original string "test"; second read returns the
BCoish> modified string sent back by the server "TEST"). This leads me
BCoish> to believe it's an internal buffer problem. Before I speculate
BCoish> further I wanted to ask if anyone has come across this before
BCoish> and what may be the cause of it.

enjoy,

-jeremy



BCoish

11/27/2003 1:06:00 AM

0

jjh-ruby-talk@vieorhythms.com wrote in message news:<87oeuzhr7h.fsf@planchet.hinegardner.org>...
> >>>>> "BCoish" == BCoish <BCoish@Dymaxion.ca> writes:
>
> BCoish> I've run into a problem that I'm hoping is not unique. I am
> BCoish> learning TCP/IP programming in Ruby and the following code
> BCoish> generates a strange result:
>
> The original code doesn't work on a Linux machine either. Here's
> slightly altered code that probably will do what you want.
>
> [jeremyhi@rapier ruby]$ cat client.rb
> # CLIENT.RB
> # =========
> require 'socket'
> s=TCPSocket.new("localhost", ARGV[0])
> s.write("test\n")
> puts s.gets
> s.close()
> [jeremyhi@rapier ruby]$
>
>
> Change server.rb to only read from the client 1 time.
>
> [jeremyhi@rapier ruby]$ cat server.rb
> # SERVER.RB
> # =========
> require "socket"
> gs = TCPserver.open(0)
> printf("server is on port %d\n", gs.addr[1])
> s = gs.accept
> line = s.gets
> puts line
> s.write(line.upcase)
> s.close
>
> BCoish> The preceeding code is used to run a server that accepts a
> BCoish> single client. The client sends the server a string, the server
> BCoish> reads and converts the string to uppercase and then sends it
> BCoish> back to the client.
>
> The server as originally written reads from the client twice, once for
> each 'gets'. Since the client is only writing once to the server this
> is probably the underlying issue.
>
> BCoish> That's how it's supposed to work and on the PC it does work.
> BCoish> However, on OpenVMS the client requires two, consecutive reads
> BCoish> in order to get the uppercased value from the server (i.e. first
> BCoish> read returns the original string "test"; second read returns the
> BCoish> modified string sent back by the server "TEST"). This leads me
> BCoish> to believe it's an internal buffer problem. Before I speculate
> BCoish> further I wanted to ask if anyone has come across this before
> BCoish> and what may be the cause of it.
>
> enjoy,
>
> -jeremy



First, thanks for the speedy response!
Second, I modified the source per your suggestions, but without success.
This is now the code I'm running:

# Client
########
require 'socket'
s=TCPSocket.new("localhost", ARGV[0])
s.write("test\n")
puts s.gets
# puts s.gets
s.close


# Server
########
require 'socket'
gs = TCPServer.open(0)
printf("server is on port %d\n", gs.addr[1])
s=gs.accept
s.write(s.gets.upcase)
s.close

Even if I break s.gets.upcase down into it's constituent parts
the problem persists. Any other ideas? (I'm fresh out) :)

Perhaps something in the actual implimentation is the same everywhere else
except for OpenVMS. Hmm, wouldn't be the first time, but it is a pain. :)

Thanks,
Brad

jjh-ruby-talk

12/2/2003 7:06:00 PM

0

>>>>> "BCoish" == BCoish <BCoish@Dymaxion.ca> writes:

Sorry for taking so long to reply.

BCoish> First, thanks for the speedy response! Second, I modified the
BCoish> source per your suggestions, but without success. This is now
BCoish> the code I'm running:

[...]

BCoish> Even if I break s.gets.upcase down into it's constituent parts
BCoish> the problem persists. Any other ideas? (I'm fresh out) :)

Have you tried doing an explicit flush on the socket? So you would have
the following?

# CLIENT.RB
# =========
require 'socket'
s=TCPSocket.new("localhost", ARGV[0])
s.write("test\n")
s.flush
puts s.gets
s.close()

# SERVER.RB
# =========
require "socket"
gs = TCPserver.open(0)
printf("server is on port %d\n", gs.addr[1])
s = gs.accept
line = s.gets
puts line
s.write(line.upcase)
s.flush
s.close

BCoish> Perhaps something in the actual implimentation is the same
BCoish> everywhere else except for OpenVMS. Hmm, wouldn't be the first
BCoish> time, but it is a pain. :)

I don't have access to an OpenVMS machine myself so I'm just throwing
out ideas here.

enjoy,

-jeremy





Brad

12/2/2003 11:52:00 PM

0

jjh-ruby-talk@vieorhythms.com wrote:

> >>>>> "BCoish" == BCoish <BCoish@Dymaxion.ca> writes:
>
> Sorry for taking so long to reply.
>
> BCoish> First, thanks for the speedy response! Second, I modified the
> BCoish> source per your suggestions, but without success. This is now
> BCoish> the code I'm running:
>
> [...]
>
> BCoish> Even if I break s.gets.upcase down into it's constituent parts
> BCoish> the problem persists. Any other ideas? (I'm fresh out) :)
>
> Have you tried doing an explicit flush on the socket? So you would have
> the following?
>
> # CLIENT.RB
> # =========
> require 'socket'
> s=TCPSocket.new("localhost", ARGV[0])
> s.write("test\n")
> s.flush
> puts s.gets
> s.close()
>
> # SERVER.RB
> # =========
> require "socket"
> gs = TCPserver.open(0)
> printf("server is on port %d\n", gs.addr[1])
> s = gs.accept
> line = s.gets
> puts line
> s.write(line.upcase)
> s.flush
> s.close
>
> BCoish> Perhaps something in the actual implimentation is the same
> BCoish> everywhere else except for OpenVMS. Hmm, wouldn't be the first
> BCoish> time, but it is a pain. :)
>
> I don't have access to an OpenVMS machine myself so I'm just throwing
> out ideas here.
>
> enjoy,
>
> -jeremy
>
>
>
>
>

Jeremy:

Thanks for the reply! Unfortunately flushing the socket seems to have
had no effect. I think there is something internally, within the socket
implementation for OpenVMS, that is the problem. Something that I am
not yet familiar with. (like another post I made to the group regarding
threads: I had only to make an O/S specific define to make ruby threads
work on OpenVMS)

If I find the answer I'll be sure to post it. And if you, or anyone
else has any further ideas I'm open to suggestions. I think I've
just about exhausted my resources. :) (But that doesn't mean I'm giving
up.)

Regards,
Brad

Clint

9/17/2008 6:14:00 PM

0

On 2008-09-17, lcpltom <lcpltom@yahoo.com> wrote:
> On Sep 17, 11:36 am, Brent Stroh <bmst...@gmail.com> wrote:
>> I hit 70 on my warlock a few weeks back, and went back to Affliction (from
>> Demonology, which I used to level 62-70) - I tend to like affliction
>> better, and it was more fun when running instances.
>>
>> So now I've got FSW, loaded with a crapload of +9 spelldmg gems.
>>
>> Which is great with a real tank in front of me. But my standard attack of
>> 'send VW, start casting UA' isn't working out too well - just UA often
>> pulls aggro off of Sparky the Wonder-Demon, let alone after I stack the
>> rest of the DoTs on top.
>>
>> So now, I find myself in melee range, getting beaten up, so channeling
>> Drain Life isn't that great of an option. Instead, I burn down the mob as
>> quickly as I can by breaking out Shadow Bolt. Which burns through my mana
>> about as fast as the mob is chewing through my HP.
>>
>> I've essentially lost the entire point of an Affliction warlock - low
>> downtime due to not needing to eat/drink. I've gone through more
>> food/drink in Netherstorm than I have in the entire pre-Netherstorm game.
>>
>> My options appear to be a) take a nap while Sparky builds aggro, b) equip
>> weaker gear when questing, c) suck it up and keep buying food.
>>
>> I've got the standard Affliction raiding spec. Ralinth/Baelgun-US if you're
>> interested in the Armory info.
>>
>> My master plan is to 'finish' Outland before WotLK - still have a few group
>> quests in BEM and Netherstorm, which shouldn't be a problem. However, I
>> haven't set foot in SMV (or Skettis, now that I think about it...) so
>> there's plenty left to solo there. Just want to make sure I haven't
>> overlooked anything obvious, here...
>>
>> -Brent
>
> First, for food, though you really don't need it, if you haven't
> completed the quest yet, do "Bring Me A Shrubbery" from Sporeggar and
> get the Everlasting Underspore Frond. At 70 its not enough to
> completely fill your health or mana bar, but its still free food every
> 24 hours.
>
> I can't look at your spec right now, but for soloing you should have
> 5/5 Fel Concentration and 2/2 in Soul Siphon, though you mention you
> are a raid spec, so you may have left this out. If so, you're kinda
> out of luck. Best way to grind with an affliction spec warlock is to
> use either the imp or the succy. Imp provides a nice way of
> recovering mana through Dark Pact, and both can be used to augment
> your damage and decrease the time the mob is hitting you.
>
> Dot up the mob, then 1 life tap should recover most, if not all, of
> the mana you just used to dot the mob. Then with 5/5 Fel
> Concentration and 2/2 in Soul Siphon, just stand there and let the mob
> hit you while you spam Drain Life. 2/2 Soul Siphon will increase the
> healing you get from Drain Life based on the number of affliction
> spells on the target. With 1/1 UA and 1/1 Siphon Life, that should
> make it 4 affliction spells at once, giving a hefty boost to your
> drain life. You should easily recover the health you lost from life
> tap, and should easilty mitigate any damage the mob is doing. Life
> tap as necessary. You should end the fight with near full health and
> mana. If you find you're lacking on mana, then make sure you have 2/2
> Improved Drain Soul, and end each fight with a Rank 1 Drain Soul while
> the dots are running. You'll get a lot of mana back with minimal
> investment, and a lot of extra shards.
>
> Of course, a lot of this is going to change here in a few weeks.

I quoted lcpltom in full because it bears repeating. Use imp and
Dark Pact and say goodbye to going OOM.

I also have the FSW set and a bunch of spell damage gems and one
of the standard Affliction raiding builds. It doesn't work as well
as when I had a full Drain Tanking build, I do get interrupted
when channeling drain life, but mobs die so quicly it doesn't
matter.

I have been 70 a bit longer, and have some good badge and rep reward
items now, so it is probably a bit easier for me to drain tank
without an actual drain tanking build. I don't think that I would
have liked the standard raid affliction build when I first hit 70
so I think that that might be your issue too.

To be honest, I didn't see a huge difference in my DPS when I went
to the raid build from the drain tanking one. I would give it a
try and see how you do in raids with the drain tank build.

Brent Stroh

9/17/2008 6:31:00 PM

0

Dingbat Charlie <noone@nowhere.com> wrote:

>I quoted lcpltom in full because it bears repeating. Use imp and
>Dark Pact and say goodbye to going OOM.

I haven't tried my imp (outside an instance) in forever - sounds like I
need to get more serious about drain tanking and ditch my blue friend for a
while.

>I have been 70 a bit longer, and have some good badge and rep reward
>items now, so it is probably a bit easier for me to drain tank
>without an actual drain tanking build. I don't think that I would
>have liked the standard raid affliction build when I first hit 70
>so I think that that might be your issue too.

I haven't gotten many (any?) badges on my warlock, yet, and I haven't
really focused on rep at all. Hit 70, make FSW, finish questing Outland -
haven't done much grinding of anything at this point.

>To be honest, I didn't see a huge difference in my DPS when I went
>to the raid build from the drain tanking one. I would give it a
>try and see how you do in raids with the drain tank build.

I just respeced to include Fel Concentration - I went from 42/0/19 to
42/19/0 (solo flavor). Since it was over lunch, I haven't had time to got
nuke anything to see how it goes. It's at
http://www.wowwiki.com/Warl... under Affliction/Demonology build for
anyone curious.

It would be nice to pull off the 3-4 mob chain pulls the rest of you
warlock types keep talking about without getting my ass kicked. :)

-Brent

Dingbat Charlie

9/17/2008 7:32:00 PM

0

On 2008-09-17, Brent Stroh <bmstroh@gmail.com> wrote:
> Dingbat Charlie <noone@nowhere.com> wrote:
>
>
> It would be nice to pull off the 3-4 mob chain pulls the rest of you
> warlock types keep talking about without getting my ass kicked. :)
>
> -Brent

3-4? You should have seen the first time I went to Terrokar to
grind feathers for rep after I dropped my felguard build for the
Affliction drain tanking build. The only think that stopped me
was running out of mobs. That silly "leash" effect where mobs
reset and run back to where they were. I had piles of dead birds
everywhere.

My record is 13 clefthoof at once, though I did have to chase a
few down and I had a chance to dark pact my mana back up and my
health was pretty low. I didnt just run in and DoT 13 clefthoof;
but when I stopped, I had 13 dead. 8-10 is typical.

I couldn't do that with a felguard, and the blueberry was out of
the questi

Catriona R

9/17/2008 7:47:00 PM

0


On Wed, 17 Sep 2008 19:32:05 +0000 (UTC), Dingbat Charlie
<danh@panix.com> wrote:

>On 2008-09-17, Brent Stroh <bmstroh@gmail.com> wrote:
>> Dingbat Charlie <noone@nowhere.com> wrote:
>>
>>
>> It would be nice to pull off the 3-4 mob chain pulls the rest of you
>> warlock types keep talking about without getting my ass kicked. :)
>>
>> -Brent
>
>3-4? You should have seen the first time I went to Terrokar to
>grind feathers for rep after I dropped my felguard build for the
>Affliction drain tanking build. The only think that stopped me
>was running out of mobs. That silly "leash" effect where mobs
>reset and run back to where they were. I had piles of dead birds
>everywhere.
>
>My record is 13 clefthoof at once, though I did have to chase a
>few down and I had a chance to dark pact my mana back up and my
>health was pretty low. I didnt just run in and DoT 13 clefthoof;
>but when I stopped, I had 13 dead. 8-10 is typical.
>
>I couldn't do that with a felguard, and the blueberry was out of
>the questi

I can do about 10 belfs at Manaforge Bnaar with the vw, chainpulling,
but it's dependent on what kind of mobs you pull though - ones who don't
hit too hard, great, dot them all up, let vw tank some, draintank the
rest and pull more every time a few die. Mobs who hit hard and fast like
the ones in netherwing mines though... 3 at a time is the highest wise
pull (I've had 4 a couple of times, bit close for comfort :-p)
--
EU-Draenor:
Sagart (70 Undead Priest)
Eilnich (70 Blood Elf Warlock)
Buinne (70 Troll Shaman)
Tairbh (62 Tauren Druid)
Balgair (70 Human Rogue)
Naomh (70 Draenei Priest)
Rosad (70 Human Warlock)
Sealgair (70 Dwarf Hunter)
Beag (60 Dwarf Paladin)

pv+usenet

9/17/2008 9:02:00 PM

0

blah@blah.com writes:
>Affliction drain tanking build. The only think that stopped me
>was running out of mobs. That silly "leash" effect where mobs
>reset and run back to where they were. I had piles of dead birds
>everywhere.

Indeed. The leashing while you're rounding up mobs drives me nuts.

>My record is 13 clefthoof at once, though I did have to chase a
>few down and I had a chance to dark pact my mana back up and my
>health was pretty low. I didnt just run in and DoT 13 clefthoof;
>but when I stopped, I had 13 dead. 8-10 is typical.

It's tricky to find anyplace where there are enough mobs to pull off huge
batches like that. One place that's pretty great for it is the geologists
next to one of the manaforges - you can easily have 10 running for you at
once, and they drop good silver, scryer items, and an enchanting pattern
I wanted. When I went for the pattern I slaughtered them for about 3 hours,
and ended up getting exalted with the scryers at the same time from all the
signets and tomes. It's a good spot for paladin aoe grinding too. Just
watch out for the occasional arcane annhilator!

>I couldn't do that with a felguard, and the blueberry was out of
>the question

I always have my succubus out, flailing at whatever she feels like. *
--
* PV something like badgers--something like lizards--and something
like corkscrews.

pv+usenet

9/17/2008 9:03:00 PM

0

Catriona R <catrionarNOSPAM@totalise.co.uk> writes:
>rest and pull more every time a few die. Mobs who hit hard and fast like
>the ones in netherwing mines though... 3 at a time is the highest wise
>pull (I've had 4 a couple of times, bit close for comfort :-p)

Oh gosh, I forgot about the mines! I used to clear out entire rooms in one
continuous pull. Good times. *
--
* PV something like badgers--something like lizards--and something
like corkscrews.