[Tutor] Socket connection refused

Nick Lunt nick at javacat.f2s.com
Mon Feb 23 15:20:31 EST 2004


Hi again,

I just downloaded python on the gf's winxp pc and ran your progams on
there. Ran exactly the same as on the linux box :)

Im gonna attach your files in this email for you to run so we can rule
out formatting issues ;)

Just run fserver.py from one dos box and fclient.py from another dos box
and let us know what happens.

Cheers
Nick.


On Mon, 23 Feb 2004 20:50:15 GMT  "Djoumy . " <deadviannou at caramail.com>
wrote:

>  I tried to launch the two apps from the windows command prompt but
> there's no changes at all. I also tried to increase the server's
> timeout with "s.settimeout(None)" but still there's no changes. This
> problem seems really odd to me, since I'd say it's coming from the
> py2exe compilation... maybe I got a wrong compilation option, I'm
> looking for informations about it but for now I'm lost :)
> 
> 
> Djoum's
> 
> 
> ------- Message original ------- 
> De: Nick Lunt <nick at javacat.f2s.com> Date: Mon, 23 Feb 2004 19:23:09 +0000 
> Sujet: Re: [Tutor] Socket connection refused 
> 
> 
> Error nr 10061 seems to indicate that there is too much load on the
> server, and the recommended fix is to increase the timeout, but that
> is when applied to SMTP/HTTP but I would expect it to be the same for
> all IP based servers.
> 
> I have done the same server/client program as you a couple of weeks
> ago, I created it on linux, then emailed it to my work and ran it fine
> on my win2k box there, so I doubt it's a windows issue.
> 
> I have had problems with py2exe on windows and linux tho even tho the
> programs were fine. I still haven't got my head around py2exe yet, I
> suspect it's more complicated than I think and Im too busy learning
> python to bother with it at the moment ;)
> 
> Have you tried running the server and client from the windows command
> prompt ? It would be interesting to know how that goes.
> 
> Cheers
> Nick.
> 
> 
> On Mon, 23 Feb 2004 20:11:55 GMT  "Djoumy . " 
> wrote:
> 
> >  Since it's only a small test program there are bugs for sure in my
> > app. Anyway thanks for your help. If it works under your Linux, can
> > the problem be coming from my Windows XP ? 
> > 
> > Djoum's
> > 
> > 
> > ------- Message original ------- 
> > De: Nick Lunt  
> > Date: Mon, 23 Feb 2004 19:00:49 +0000 
> > Sujet: Re: [Tutor] Socket connection refused 
> > 
> > 
> > Hi there,
> > 
> > I'm also new at python but I copied/pasted your source code and it
> > ran fine after I'd sorted out the formatting, but I suspect that was
> > because of my email client.
> > 
> > Anyway it runs on linux ok, the only issue I found was that when
> > connecting, then clicking on the OK button on the 'Hello World'
> > message I get the following TkDialog up "Can't connect to the server
> > 127.0.0.1 EISCONN"
> > 
> > Sorry I can't be of anymore help.
> > 
> > Cheers
> > Nick.
> > 
> > 
> > On Mon, 23 Feb 2004 19:09:13 GMT  "Vianus le Fus "
> >  wrote:
> > 
> > > Hello,
> > > I'm a newbie to python so please don't be too hard with me :)
> > > I'm encountering problems using socket connections in my programs.
> > > My goal is to create a small chat program so I begin with the
> > > beginning : two really small apps, one for the server and one for
> > > the client. The server is here to listen to one port and to resend
> > > its own data to the client that's connected to the port.
> > > 
> > > I have found two ways to test this : I compile the server with
> > > py2exe and launch it, then I can run the client either running the
> > > module under IDLE or compiling it with py2exe. And there's my
> > > problem : it works under IDLE (connection is set and the client
> > > receives its own data) but connection fails when using the exe
> > > client.... it says"error 10061 : Connection refused". I don't have
> > > any firewall nor other running programs that could block the
> > > socket, I really don't understand what's the difference using
> > > py2exe or not!!
> > > 
> > > Please does someone know why the first method works and not the
> > > other?
> > > 
> > > -----------------------------------------------------
> > > Serveur.py
> > > -----------------------------------------------------
> > > import socket
> > > 
> > > HOST = '127.0.0.1'
> > > PORT = 50007
> > > 
> > > s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> > > s.bind((HOST, PORT))
> > > s.listen(1)
> > > conn, addr = s.accept()
> > > print 'Connected by', addr
> > > while 1:
> > >     data = conn.recv(1024)
> > >     if not data: break
> > >     conn.send(data)
> > > conn.close()
> > > 
> > > 
> > > 
> > > -----------------------------------------------------
> > > Client.py
> > > -----------------------------------------------------
> > > import errno
> > > import socket
> > > from Tkinter import *
> > > import tkMessageBox
> > > 
> > > class Application(Frame):
> > >     def __init__(self, master=None):
> > >         Frame.__init__(self, master)
> > >         
> > >         self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> > >         self.connected = 0
> > >         self.data = ''
> > >         
> > >         self.pack()
> > >         self.createWidgets()
> > > 
> > >         
> > >     def createWidgets(self):
> > >         self.btn_quit = Button(self)
> > >         self.btn_quit["text"] = "QUIT"
> > >         self.btn_quit["fg"]   = "red"
> > >         self.btn_quit["command"] =  self.end
> > > 
> > >         self.btn_quit.pack({"side": "left"})
> > > 
> > >         self.btn_connect = Button(self)
> > >         self.btn_connect["text"] = "Connect",
> > >         self.btn_connect["command"] = self.connect
> > > 
> > >         self.btn_connect.pack({"side": "right"})
> > > 
> > > 
> > >     def connect(self) :
> > >         try:
> > >             self.s.connect(('127.0.0.1', 50007))
> > >             self.connected = 1
> > >             
> > >         except socket.error, msg:
> > >             tkMessageBox.showinfo(title='Connexion error',
> > >             message='Can\'t connect \
> > > to the server 127.0.0.1' + '\n' + str(errno.errorcode[msg[0]]))
> > > 
> > >         if self.connected == 1 :
> > >             self.s.send('Hello, world')
> > >             self.data = self.s.recv(1024)
> > >             print 'Received', str(self.data)
> > >             tkMessageBox.showinfo(title='Data received !!',
> > >             message=str(self.data))
> > > 
> > > 
> > >     def end(self) :
> > >         self.s.close()
> > >         self.quit()
> > > 
> > > 
> > > # MAIN
> > > app = Application()
> > > app.mainloop()
> > > -----------------------------------------------------
> > > 
> > > Plus simple, plus fiable, plus rapide : découvrez le nouveau
> > > Caramail- http://www.caramail.lycos.fr
> > > 
> > > 
> > 
> > _______________________________________________
> > Tutor maillist  -  Tutor at python.org
> > http://mail.python.org/mailman/listinfo/tutor
> > 
> > Plus simple, plus fiable, plus rapide : découvrez le nouveau
> > Caramail- http://www.caramail.lycos.fr
> > 
> > 
> 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
> 
> Plus simple, plus fiable, plus rapide : découvrez le nouveau Caramail
> - http://www.caramail.lycos.fr
> 
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fclient.py
Type: application/octet-stream
Size: 1324 bytes
Desc: not available
Url : http://mail.python.org/pipermail/tutor/attachments/20040223/563c0a19/fclient.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fserver.py
Type: application/octet-stream
Size: 299 bytes
Desc: not available
Url : http://mail.python.org/pipermail/tutor/attachments/20040223/563c0a19/fserver.obj


More information about the Tutor mailing list