# Sockets are Killing Me!

**URL:** <https://www.ruby-forum.com/t/sockets-are-killing-me/190176>\
**Category:** Rails\
**Created:** [June 17, 2010, 4:22pm UTC](https://www.ruby-forum.com/t/sockets-are-killing-me/190176 "2010-06-17T16:22:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![djames](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7ab992/32.png) [@djames](https://www.ruby-forum.com/u/djames)\
**Post date:** [June 17, 2010, 4:22pm UTC](https://www.ruby-forum.com/t/sockets-are-killing-me/190176/1 "2010-06-17T16:22:11Z")

</div>

I’ve been trying to interface to the onlineNIC API which uses  
sockets. The following 4 lines of test code illustrate my problem:

socket=TCPSocket::new(‘ip’,‘port’)  
puts(“Connect:\n”+socket.read()+"\n\n")  
socket.print(login\_request)  
puts(“Login:\n”+socket.read()+"\n\n")

In the actual code the real IP address and port number are substituted  
for ‘ip’ and ‘port’ in the above.

In the first line I establish a connection. In the second line I  
print the response. These 2 lines work perfectly. In the 3ed line I  
attempt to submit a request and in the 4th line I attempt to print the  
response returned for that request submission. I get nothing back.

I’m real green with sockets. With that in mind, my question is this:  
Is there something fundamentally wrong with what I have done in the  
3ed and 4th lines; or, should I expect this to work? TIA for any  
input. BTW, I’ve appended my full test code in the event that it is  
somehow relevant. Thanks again.

```
     ... doug

```

Full Test Code:

require ‘socket’  
login\_request=\<\<’\_ALTO’

\<?xml version="1.0" encoding="UTF-8" standalone="no"?\> client Login 135610 135610A1276479316B171 4bdee845b6e6dc67754b038f2b08bf74 \_ALTO socket=TCPSocket::new('ip','port') puts("Connect:\n"+socket.read()+"\n\n") socket.print(login\_request) puts("Login:\n"+socket.read()+"\n\n")
