Socket issues

T

twistedduck9

Hi all

I've been trying to set up sockets on my server (running Apache/2.2.3)
using python and I'm confused as to why it doesn't work.

I set up a simple listening script which runs without error, and works
if a connecting script is run on the same server. However, if I try to
connect using Telnet it doesn't work. I am definetly using the public
IP address (79.99.43.58:2727).

The weird thing is that I have the same problem if I make the socket
in PHP, and even more weird is that sockets used to work, but now do
not (and as far as I can tell, I have changed nothing).

Any ideas?

Thanks,
Sunil
 
G

Gary M. Josack

twistedduck9 said:
Hi all

I've been trying to set up sockets on my server (running Apache/2.2.3)
using python and I'm confused as to why it doesn't work.

I set up a simple listening script which runs without error, and works
if a connecting script is run on the same server. However, if I try to
connect using Telnet it doesn't work. I am definetly using the public
IP address (79.99.43.58:2727).

The weird thing is that I have the same problem if I make the socket
in PHP, and even more weird is that sockets used to work, but now do
not (and as far as I can tell, I have changed nothing).

Any ideas?

Thanks,
Sunil
With no code it's hard to tell if there's an issue there, but if the
same code worked before and still works locally I'm going to guess firewall.
 
T

twistedduck9

My hosting provider (Streamline) have said that there is no firewall
(it's a dedicated server). Either way the code I'm using is:

Listening socket:
import socket
mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
mysock.bind (('79.99.43.58', 2727))
mysock.listen(1)
while True:
channel, details = mysock.accept()
print channel.recv(100)
channel.send ('Got a message.')
channel.close()

Sending socket:
import socket
mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
mysock.connect(('79.99.43.58', 2727))
mysock.send('test');
mysock.close()

Thanks for the response!
 
J

Jeff McNeil

My hosting provider (Streamline) have said that there is no firewall
(it's a dedicated server). Either way the code I'm using is:

Listening socket:
import socket
mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
mysock.bind (('79.99.43.58', 2727))
mysock.listen(1)
while True:
   channel, details = mysock.accept()
   print channel.recv(100)
   channel.send ('Got a message.')
   channel.close()

Sending socket:
import socket
mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
mysock.connect(('79.99.43.58', 2727))
mysock.send('test');
mysock.close()

Thanks for the response!


Any chance you've got IP Tables running on it? I've spent hours
debugging strange problems before only for them to turn out to be
vendor default IP tables configurations (Thanks, Red Hat!). In fact,
'iptables -L -n' has turned into one of the first things I do whenever
I have any sort of problem at all. Along the same line, could always
be a SELinux policy as well. The second thing I usually do?
'setenforce 0.'

Also, by "doesn't work", what do you mean? Does it just hang and
never reply? Do you get a connection refused message?

Jeff
mcjeff.blogspot.com
 
T

twistedduck9

Any chance you've got IP Tables running on it? I've spent hours
debugging strange problems before only for them to turn out to be
vendor default IP tables configurations (Thanks, Red Hat!). In fact,
'iptables -L -n' has turned into one of the first things I do whenever
I have any sort of problem at all.  Along the same line, could always
be a SELinux policy as well.  The second thing I usually do?
'setenforce 0.'

Also, by "doesn't work", what do you mean?  Does it just hang and
never reply? Do you get a connection refused message?

Jeff
mcjeff.blogspot.com

I seriously love you now. I still don't understand why it worked
before... Also, does this IP tables thing mean that there WAS a
firewall blocking the connection? If so, I think I'll have a go at my
hosting provider...
iptables -I RH-Firewall-1-INPUT 1 -p tcp --dport 2727 -j ACCEPT

Thank you for your response, you've saved many hours of pulling my
hair out.

Sunil

(I think I may have replied in the wrong place, I haven't used groups
before)
 

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,200
Messages
2,571,046
Members
47,646
Latest member
xayaci5906

Latest Threads

Top