server connection

B

Barry Sperling

Hi,
I'm trying to learn some basic networking and I've tried to run the
code from the Pragmatic Programmer in the Class TCPServer which connects
to a server and then returns the date and time ( as in Steven's
Networking book ). I am using a W2K machine and have started an Apache
service, which comes attached to Oracle. When I use 127.0.0.1 or call a
server that I am linked to on a LAN, I get the same error
"Only one usage of each socket address is normally permitted"

I get this error when I run it as an rbw through Scite, or from the
command line. What do I need to do to make a server connection?
Thanks,
Barry
 
B

Brian Schröder

Hi,
I'm trying to learn some basic networking and I've tried to run the
code from the Pragmatic Programmer in the Class TCPServer which connects
to a server and then returns the date and time ( as in Steven's
Networking book ). I am using a W2K machine and have started an Apache
service, which comes attached to Oracle. When I use 127.0.0.1 or call a
server that I am linked to on a LAN, I get the same error
"Only one usage of each socket address is normally permitted"

I get this error when I run it as an rbw through Scite, or from the
command line. What do I need to do to make a server connection?
Thanks,
Barry
Maybe you are opening up a TCPServer that tries to listen on port 80 or some other port that is already in usage.

There is some command in windows to list the used ports, I just don't rember which.

For a simple TCP example program see the explanation in my ruby-course slides and the chat sources:

http://ruby.brian-schroeder.de/course/


Regards,

Brian
 
S

Sea&Gull

Maybe you are opening up a TCPServer that tries to listen
on port 80 or some other port that is already in usage.

There is some command in windows to list the used ports, I just don't rember which.

netstat -a
 
B

Barry Sperling

Thank you Brian and S&G,
But I haven't gotten much further. The "netstat - a" gave me a list of
ports that were "Active Connections" and 80 was one of the ones that the
server was listening on, though the only 2 that were established were
2472 and 2473. For connections with port 80, on my computer or to
others, the same error pops up:

Only one usage of each socket address (protocol/network address/port)
(Errno::EADDRINUSE)
is normally permitted. - bind(2) from Chat_Server.rbw:6:in `new'
from Chat_Server.rbw:6

As I said, I believe that I am trying to contact an Apache server within
an Oracle installation and the Oracleora81HTTPSerever service has been
started.

This code is sufficient to generate the error:

require 'socket'

host, port = '127.0.0.1', 80
server = TCPServer.new(host,port)

Thanks again for your time and if anything occurs to anybody about my
problem I'd appreciate a suggestion.
Barry
 
D

Dick Davies

* Barry Sperling said:
Thank you Brian and S&G,
But I haven't gotten much further. The "netstat - a" gave me a list
of ports that were "Active Connections" and 80 was one of the ones that the
server was listening on, though the only 2 that were established were
2472 and 2473. For connections with port 80, on my computer or to
others, the same error pops up:

Only one usage of each socket address (protocol/network address/port)
(Errno::EADDRINUSE)
is normally permitted. - bind(2) from Chat_Server.rbw:6:in `new'
from Chat_Server.rbw:6

As I said, I believe that I am trying to contact an Apache server within
an Oracle installation and the Oracleora81HTTPSerever service has been
started.

This code is sufficient to generate the error:

require 'socket'

host, port = '127.0.0.1', 80
server = TCPServer.new(host,port)

You're trying to *listen* on port 80 here. If something else is already
listening on that port (as you said earlier), the TCPServer.new() call
will fail. Which is what's happening.

Are you wanting to connect to port 80 as a client? You say

' I am trying to contact an Apache server'

so I assume you want to talk *to* port 80, not *on* port 80.

An analogy would be trying to call the operator by breaking into the
exchange and picking up their phone, rather than ringing them...

Try TCPSocket rather than TCPServer (or open-uri or Net::HTTP if you
just want to GET/POST to the webserver).
 

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

Members online

Forum statistics

Threads
474,164
Messages
2,570,898
Members
47,440
Latest member
YoungBorel

Latest Threads

Top