LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 08-05-2005, 07:56 AM   #1
warnetgm
Member
 
Registered: Aug 2005
Distribution: Ubuntu
Posts: 30

Rep: Reputation: 15
Linux Connection Refused WinXP


I'm creating a simple python program at a client computer (Linux Ubuntu) :
#import sys
from socket import *

def init():
s = socket(AF_INET, SOCK_STREAM)
hostname = '192.168.100.100'
port = 1973
s.connect((hostname, port))
code = chr(203) + chr(214) + chr(201) + chr(198) + chr(001)
stationid = '30';
s.send(code + 'TEST LINUX');

this will connect to a Server program I'm create on WinXP Computer
But got :

>>> import client
>>> client.init()
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "client.py", line 8, in init
s.connect((hostname, port))
File "<string>", line 1, in connect

socket.error: (111, 'Connection refused')
>>>

Trying to ping the server 192.168.100.100, it replies nicely
Already input port 1973 from all computers on both firewall inbound and outbound.
Even trying to disable or turn off both computer firewall
But still it the same 111, connection refuse
Trying telnet 192.168.100.100 1973 the same refused

What is wrong ?

Thank You
 
Old 08-06-2005, 07:49 PM   #2
carl.waldbieser
Member
 
Registered: Jun 2005
Location: Pennsylvania
Distribution: Kubuntu
Posts: 197

Rep: Reputation: 32
It's a little hard to tell without seeing what your server is doing. Are you sure it was listening on the correct port?
 
Old 08-09-2005, 05:16 AM   #3
warnetgm
Member
 
Registered: Aug 2005
Distribution: Ubuntu
Posts: 30

Original Poster
Rep: Reputation: 15
I'm sure, because I'm also creating a client program for Windows XP it is work great if both is Windows OS, but when I'm doing it in Python Linux got problem like that

Both linux - winXP computer can see each other in network, and they can send and receive file on each file explorer, so the network connection is ok. Both can ping each other nicely too, just my python program always got conection refused when sending to a server program (which I create), though it is ok when another client connect and do several communication with the server when the client is WinXP.

is there anything I should know more with windows - linux socket programming ?
does my program already correct ? or something should be tweaked on the windows or linux side to allow the connection passing?

Thank You
 
Old 08-09-2005, 07:08 PM   #4
carl.waldbieser
Member
 
Registered: Jun 2005
Location: Pennsylvania
Distribution: Kubuntu
Posts: 197

Rep: Reputation: 32
Quote:
Originally posted by warnetgm
I'm sure, because I'm also creating a client program for Windows XP it is work great if both is Windows OS, but when I'm doing it in Python Linux got problem like that
Thank You
So you are saying that you run the same (client) python program from WinXP, and you can connect to the server? That is a little odd. Everything you are doing sounds correct. If your Linux box is not blocking outbound port 1973 (check with "iptables -n -L") and your server is not blocking inbound port 1973 and the server is running, then it should work fine. Do you have any other servers running on WinXP like an FTP server or a web server? Can you get a socket to connect to one of those ports?
 
Old 08-10-2005, 04:59 AM   #5
warnetgm
Member
 
Registered: Aug 2005
Distribution: Ubuntu
Posts: 30

Original Poster
Rep: Reputation: 15
iptables -n -L :
Chain OUTBOUND (1 references)
target prot opt source destination
ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0
ACCEPT all -- 0.0.0.0/0 192.168.100.100

.......

ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:1973
ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:1973
LOG all -- 0.0.0.0/0 0.0.0.0/0 LOG flags 0 level 6 prefix `Outbound '
REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable

The working client (which in WinXP) crated using Delphi and so the Server program. I'm using python only on Linux Client. But the code exactly the same as in python, I'm just translate it into python.
I do place outbound policy to allow port 1973 to all computers
In windows side the firewall is norton antivirus worm protection and I do open inbound port 1973 there
Even I've tried several times on both deactivate the firewall altogether, but to no avail...

Is there anything I'm miss here ?
Or socket coding from Delphi and Python need something extra things to do ?
Isn't that socket is standard accros platform ?

Thank You
 
Old 08-10-2005, 05:49 PM   #6
carl.waldbieser
Member
 
Registered: Jun 2005
Location: Pennsylvania
Distribution: Kubuntu
Posts: 197

Rep: Reputation: 32
Here are a couple ideas:

It looks like your Linux box is running some sort of firewall (maybe firestarter?). Try disabling it and then:
Code:
# iptables -F
to flush the chains in the filter table. That should pretty much eliminate the Linux firewall as a problem.

Next, you might want to install ethereal or windump on your XP machine so you can watch the packets come over. You can compare the exchanges between a working and a non-working client. Figure out what the difference is.

The sockets model is supposed to be the same across platforms in theory, but I am pretty sure that there are some implementation differences.
 
Old 08-11-2005, 08:01 AM   #7
warnetgm
Member
 
Registered: Aug 2005
Distribution: Ubuntu
Posts: 30

Original Poster
Rep: Reputation: 15
I think needed a clearence here, is socket(AF_INET, SOCK_STREAM) create a TCP or UDP socket ?
Because I'm using UDP protocol on the WinXP side.
is DATAGRAM the correct one ?
How to correct it in python, please help

Thank You
 
Old 08-11-2005, 08:07 AM   #8
warnetgm
Member
 
Registered: Aug 2005
Distribution: Ubuntu
Posts: 30

Original Poster
Rep: Reputation: 15
wow Succeess SOCK_DGRM

Anyway thank you Carl, because u point out of using ethreal I'm realize that I didn't use the same protocol at the first place.

THANK YOU ALOT CARL, you are very GENIUS
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Socket Connection Failed: 111 Connection Refused degraffenried13 Linux - General 3 05-31-2009 01:17 AM
ircd.conf: "Connection failed. Error: Connection refused" hamish Linux - Software 3 03-10-2005 07:23 AM
Linux-Terminal-Server connection refused sdecha Linux - Networking 3 12-10-2003 08:18 AM
SSH connection refused using linux box 90coders Linux - Security 3 10-18-2003 02:53 AM
Parallel connection between WinXP & Linux pickupapenguin Linux - Networking 2 09-17-2003 03:35 AM


All times are GMT -5. The time now is 06:21 PM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration