Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #33991 > unrolled thread

please help me to debud my local chat network program

Started byMinh Dang <dangbaminh.it@gmail.com>
First post2012-11-27 18:50 -0800
Last post2012-11-30 20:11 +0000
Articles 20 on this page of 24 — 5 participants

Back to article view | Back to comp.lang.python


Contents

  please help me to debud my local chat network program Minh Dang <dangbaminh.it@gmail.com> - 2012-11-27 18:50 -0800
    Re: please help me to debud my local chat network program Terry Reedy <tjreedy@udel.edu> - 2012-11-27 22:48 -0500
    Re: please help me to debud my local chat network program Chris Angelico <rosuav@gmail.com> - 2012-11-28 15:03 +1100
      Re: please help me to debud my local chat network program Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-11-28 21:12 +0000
        Re: please help me to debud my local chat network program Minh Dang <dangbaminh.it@gmail.com> - 2012-11-28 18:48 -0800
    Re: please help me to debud my local chat network program Minh Dang <dangbaminh.it@gmail.com> - 2012-11-27 21:47 -0800
      Re: please help me to debud my local chat network program Chris Angelico <rosuav@gmail.com> - 2012-11-28 17:33 +1100
    Re: please help me to debud my local chat network program Minh Dang <dangbaminh.it@gmail.com> - 2012-11-28 02:52 -0800
      Re: please help me to debud my local chat network program Chris Angelico <rosuav@gmail.com> - 2012-11-28 22:16 +1100
        Re: please help me to debud my local chat network program Minh Dang <dangbaminh.it@gmail.com> - 2012-11-28 03:17 -0800
        Re: please help me to debud my local chat network program Minh Dang <dangbaminh.it@gmail.com> - 2012-11-28 03:17 -0800
    Re: please help me to debud my local chat network program Minh Dang <dangbaminh.it@gmail.com> - 2012-11-28 03:10 -0800
      Re: please help me to debud my local chat network program Chris Angelico <rosuav@gmail.com> - 2012-11-28 22:17 +1100
    Re: please help me to debud my local chat network program Minh Dang <dangbaminh.it@gmail.com> - 2012-11-28 03:23 -0800
    Re: please help me to debud my local chat network program Minh Dang <dangbaminh.it@gmail.com> - 2012-11-28 03:57 -0800
      Re: please help me to debud my local chat network program Chris Angelico <rosuav@gmail.com> - 2012-11-28 23:24 +1100
        Re: please help me to debud my local chat network program Minh Dang <dangbaminh.it@gmail.com> - 2012-11-28 06:10 -0800
          Re: please help me to debud my local chat network program Chris Angelico <rosuav@gmail.com> - 2012-11-29 01:21 +1100
            Re: please help me to debud my local chat network program Minh Dang <dangbaminh.it@gmail.com> - 2012-11-28 07:27 -0800
            Re: please help me to debud my local chat network program Minh Dang <dangbaminh.it@gmail.com> - 2012-11-28 07:27 -0800
        Re: please help me to debud my local chat network program Minh Dang <dangbaminh.it@gmail.com> - 2012-11-28 06:10 -0800
    Re: please help me to debud my local chat network program Minh Dang <dangbaminh.it@gmail.com> - 2012-11-29 01:03 -0800
      Re: please help me to debud my local chat network program Chris Angelico <rosuav@gmail.com> - 2012-11-29 20:13 +1100
      RE: please help me to debud my local chat network program "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-11-30 20:11 +0000

Page 1 of 2  [1] 2  Next page →


#33991 — please help me to debud my local chat network program

FromMinh Dang <dangbaminh.it@gmail.com>
Date2012-11-27 18:50 -0800
Subjectplease help me to debud my local chat network program
Message-ID<8edb652f-c48f-4758-a315-3ecc8070267d@googlegroups.com>
Hello everybody, i am doing my project: local network chat using python
here is my file
http://www.mediafire.com/?cc2g9tmsju0ba2m
when i compile client.py, there is some bug
Traceback (most recent call last):
File "C:\Users\MINH_IT\workspace\project\src\project\pclient.py", line 303, in <module>
sys.exit(main())
File "C:\Users\MINH_IT\workspace\project\src\project\pclient.py", line 42, in main
servIP = broadcast()
File "C:\Users\MINH_IT\workspace\project\src\project\pclient.py", line 79, in broadcast
udpSock.bind((broadcastIP, broadcastPort))
OSError: [WinError 10049] The requested address is not valid in its context
Please help me to debud it, thank so much.

[toc] | [next] | [standalone]


#33993

FromTerry Reedy <tjreedy@udel.edu>
Date2012-11-27 22:48 -0500
Message-ID<mailman.327.1354074525.29569.python-list@python.org>
In reply to#33991
On 11/27/2012 9:50 PM, Minh Dang wrote:
> Hello everybody, i am doing my project: local network chat using python
> here is my file
> http://www.mediafire.com/?cc2g9tmsju0ba2m

I am not familiar with .rar files and whether I can open them. Better to 
upload a standard .zip.

> when i compile client.py, there is some bug
> Traceback (most recent call last):
> File "C:\Users\MINH_IT\workspace\project\src\project\pclient.py", line 303, in <module>
> sys.exit(main())

sys.exit is not usually necessary. Just 'main()' should be sufficient.

> File "C:\Users\MINH_IT\workspace\project\src\project\pclient.py", line 42, in main
> servIP = broadcast()
> File "C:\Users\MINH_IT\workspace\project\src\project\pclient.py", line 79, in broadcast
> udpSock.bind((broadcastIP, broadcastPort))
> OSError: [WinError 10049] The requested address is not valid in its context

The broadcastIP, which you defined elsewhere, whatever it is, is not 
valid for udpSock, also defined elsewhere.

-- 
Terry Jan Reedy

[toc] | [prev] | [next] | [standalone]


#33994

FromChris Angelico <rosuav@gmail.com>
Date2012-11-28 15:03 +1100
Message-ID<mailman.328.1354075385.29569.python-list@python.org>
In reply to#33991
On Wed, Nov 28, 2012 at 1:50 PM, Minh Dang <dangbaminh.it@gmail.com> wrote:
> Hello everybody, i am doing my project: local network chat using python
> here is my file
> http://www.mediafire.com/?cc2g9tmsju0ba2m

Hmm. Might I recommend some other means of sharing your code? The
unrar-free utility from the Debian repo won't extract more than the
first file (accounts.txt), and I don't know if that's a problem with
unrar-free or your file. A better-known format like zip or tar.gz
would make things easier.

> when i compile client.py, there is some bug
> Traceback (most recent call last):
> File "C:\Users\MINH_IT\workspace\project\src\project\pclient.py", line 303, in <module>
> sys.exit(main())
> File "C:\Users\MINH_IT\workspace\project\src\project\pclient.py", line 42, in main
> servIP = broadcast()
> File "C:\Users\MINH_IT\workspace\project\src\project\pclient.py", line 79, in broadcast
> udpSock.bind((broadcastIP, broadcastPort))
> OSError: [WinError 10049] The requested address is not valid in its context
> Please help me to debud it, thank so much.

What's the broadcastIP address you're using? (As mentioned above, I
can't see your source code.) Is it the appropriate address for one of
your interfaces?

Broadcast UDP is a bit tricky sometimes. You need to explicitly enable
broadcasting on the socket -  I've not done this in Python but two
seconds with Google suggests that this is needed:

udpSock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)

You may have already done this, but I don't know without seeing your code.

My crystal ball tells me that you're trying to bind to a broadcast
address (eg 192.168.0.255). This is incorrect; you need to instead
bind to your own IP address (eg 192.168.0.17). You can probably just
do this:

udpSock.bind(('', broadcastPort))

However, my crystal ball has been playing up a bit lately, so it's
hard to be sure.

ChrisA

[toc] | [prev] | [next] | [standalone]


#34036

FromJorgen Grahn <grahn+nntp@snipabacken.se>
Date2012-11-28 21:12 +0000
Message-ID<slrnkbcvik.1jc.grahn+nntp@frailea.sa.invalid>
In reply to#33994
On Wed, 2012-11-28, Chris Angelico wrote:
> On Wed, Nov 28, 2012 at 1:50 PM, Minh Dang <dangbaminh.it@gmail.com> wrote:
>> Hello everybody, i am doing my project: local network chat using python
>> here is my file
>> http://www.mediafire.com/?cc2g9tmsju0ba2m
>
> Hmm. Might I recommend some other means of sharing your code? The
> unrar-free utility from the Debian repo won't extract more than the
> first file (accounts.txt), and I don't know if that's a problem with
> unrar-free or your file. A better-known format like zip or tar.gz
> would make things easier.

Or a Git repository at github.com or similar.

/Jorgen

-- 
  // Jorgen Grahn <grahn@  Oo  o.   .     .
\X/     snipabacken.se>   O  o   .

[toc] | [prev] | [next] | [standalone]


#34046

FromMinh Dang <dangbaminh.it@gmail.com>
Date2012-11-28 18:48 -0800
Message-ID<e39b38a4-15f8-4983-9250-b905dfce17e8@googlegroups.com>
In reply to#34036
ok, here is my code, zip
http://www.mediafire.com/?ob4kokda81fj6xc

[toc] | [prev] | [next] | [standalone]


#33999

FromMinh Dang <dangbaminh.it@gmail.com>
Date2012-11-27 21:47 -0800
Message-ID<6dfb8bda-3a54-47ce-b511-fd6945b4d4cf@googlegroups.com>
In reply to#33991
ok, here is my code, zip
http://www.mediafire.com/?ob4kokda81fj6xc

[toc] | [prev] | [next] | [standalone]


#34001

FromChris Angelico <rosuav@gmail.com>
Date2012-11-28 17:33 +1100
Message-ID<mailman.329.1354084425.29569.python-list@python.org>
In reply to#33999
On Wed, Nov 28, 2012 at 4:47 PM, Minh Dang <dangbaminh.it@gmail.com> wrote:
> ok, here is my code, zip
> http://www.mediafire.com/?ob4kokda81fj6xc

Thanks! That's a distinct improvement :)

That code doesn't exactly match the traceback, though; there's
client.py not pclient.py and the line numbers don't match. So I have
to just guess that the error is the same. However, I can see an
immediate problem.

def broadcast():
    broadcastIP = "<broadcast>"
    broadcastPort = 9999

That's not a valid broadcast IP :)

I think you probably want to bind to "" (aka "any address").

ChrisA

[toc] | [prev] | [next] | [standalone]


#34008

FromMinh Dang <dangbaminh.it@gmail.com>
Date2012-11-28 02:52 -0800
Message-ID<b6445a85-4e84-4c9a-b947-d167ea03fa14@googlegroups.com>
In reply to#33991
but, how can I fix it?

[toc] | [prev] | [next] | [standalone]


#34010

FromChris Angelico <rosuav@gmail.com>
Date2012-11-28 22:16 +1100
Message-ID<mailman.332.1354101366.29569.python-list@python.org>
In reply to#34008
On Wed, Nov 28, 2012 at 9:52 PM, Minh Dang <dangbaminh.it@gmail.com> wrote:
> but, how can I fix it?

I can't say that for sure, but did you read the bit at the end of my
last post beginning "I think you probably want"? Try doing that, see
what happens.

ChrisA

[toc] | [prev] | [next] | [standalone]


#34011

FromMinh Dang <dangbaminh.it@gmail.com>
Date2012-11-28 03:17 -0800
Message-ID<4a881fad-e901-4f9a-874f-5d7e97c6ac57@googlegroups.com>
In reply to#34010
ok, in client.py, i change broadcastIP = "broadcast" to broadcastIP = "127.0.0.1",it's ok, but there are some bugs
sys.exit(main())
rQueue, wQueue, xQueue = select.select(inputs, [], []) 

[toc] | [prev] | [next] | [standalone]


#34012

FromMinh Dang <dangbaminh.it@gmail.com>
Date2012-11-28 03:17 -0800
Message-ID<mailman.334.1354101483.29569.python-list@python.org>
In reply to#34010
ok, in client.py, i change broadcastIP = "broadcast" to broadcastIP = "127.0.0.1",it's ok, but there are some bugs
sys.exit(main())
rQueue, wQueue, xQueue = select.select(inputs, [], []) 

[toc] | [prev] | [next] | [standalone]


#34009

FromMinh Dang <dangbaminh.it@gmail.com>
Date2012-11-28 03:10 -0800
Message-ID<0776c5d4-05c6-4bea-af12-360fcc67728e@googlegroups.com>
In reply to#33991
ok, in client.py, i change broadcastIP = "broadcast" to broadcastIP = "127.0.0.1" but there are some bugs 
sys.exit(main())
rQueue, wQueue, xQueue = select.select(inputs, [], []) 

[toc] | [prev] | [next] | [standalone]


#34013

FromChris Angelico <rosuav@gmail.com>
Date2012-11-28 22:17 +1100
Message-ID<mailman.333.1354101477.29569.python-list@python.org>
In reply to#34009
On Wed, Nov 28, 2012 at 10:10 PM, Minh Dang <dangbaminh.it@gmail.com> wrote:
> ok, in client.py, i change broadcastIP = "broadcast" to broadcastIP = "127.0.0.1" but there are some bugs

I doubt that that will work either. And you may need to be a little
clearer on what you mean by "there are some bugs" - is it doing what
you don't expect? Are you getting an exception?

Tips: http://catb.org/~esr/faqs/smart-questions.html

ChrisA

[toc] | [prev] | [next] | [standalone]


#34014

FromMinh Dang <dangbaminh.it@gmail.com>
Date2012-11-28 03:23 -0800
Message-ID<80e0fe90-1f33-4544-8d9c-16c06db50f9b@googlegroups.com>
In reply to#33991
yes, still have 2 bugs:
sys.exit(main())
rQueue, wQueue, xQueue = select.select(inputs, [], []) 

[toc] | [prev] | [next] | [standalone]


#34015

FromMinh Dang <dangbaminh.it@gmail.com>
Date2012-11-28 03:57 -0800
Message-ID<3aa89e19-05e9-4593-95c8-e142297339a6@googlegroups.com>
In reply to#33991
please help me, after changing broadcast, there are 2 bugs: 
if __name__ == "__main__":
    sys.exit(main())
and 

rQueue, wQueue, xQueue = select.select(inputs, [], []) 
please help me

[toc] | [prev] | [next] | [standalone]


#34016

FromChris Angelico <rosuav@gmail.com>
Date2012-11-28 23:24 +1100
Message-ID<mailman.335.1354105450.29569.python-list@python.org>
In reply to#34015
On Wed, Nov 28, 2012 at 10:57 PM, Minh Dang <dangbaminh.it@gmail.com> wrote:
> please help me, after changing broadcast, there are 2 bugs:
> if __name__ == "__main__":
>     sys.exit(main())
> and
>
> rQueue, wQueue, xQueue = select.select(inputs, [], [])
> please help me

By "bug", I'm guessing you mean one of two things:

1) The program fails to run, and an exception is given that points to
one of these lines, or
2) The program runs, but does something different from what you expect it to do.

If it's the first, what's the exception? If the second, what do you
expect and what happens?

You need to provide more information. Check out the link I gave you on
how to ask questions; it's very helpful.

ChrisA

[toc] | [prev] | [next] | [standalone]


#34020

FromMinh Dang <dangbaminh.it@gmail.com>
Date2012-11-28 06:10 -0800
Message-ID<0a66d722-e46c-4230-a39c-2115d84b626e@googlegroups.com>
In reply to#34016
yes, it's run but appear: 
in server: Server is ready.
Accepted connection from  ('127.0.0.1', 5000)
End connection from ('127.0.0.1', 5000)
after connected, server close.
in client: Connected to server at  127.0.0.1 : 4000
Traceback (most recent call last):
  File "C:\Users\MINH_IT\workspace\project\src\project\client.py", line 303, in <module>
    sys.exit(main())
  File "C:\Users\MINH_IT\workspace\project\src\project\client.py", line 60, in main
    rQueue, wQueue, xQueue = select.select(inputs, [], []) 
OSError: [WinError 10038] An operation was attempted on something that is not a socket
there are 2 problems.

[toc] | [prev] | [next] | [standalone]


#34022

FromChris Angelico <rosuav@gmail.com>
Date2012-11-29 01:21 +1100
Message-ID<mailman.337.1354112478.29569.python-list@python.org>
In reply to#34020
On Thu, Nov 29, 2012 at 1:10 AM, Minh Dang <dangbaminh.it@gmail.com> wrote:
>   File "C:\Users\MINH_IT\workspace\project\src\project\client.py", line 60, in main
>     rQueue, wQueue, xQueue = select.select(inputs, [], [])
> OSError: [WinError 10038] An operation was attempted on something that is not a socket

Have a look at that line of code - specifically, look at what's in
inputs. One of them perhaps isn't a socket. Tip: The print function is
your friend.

ChrisA

[toc] | [prev] | [next] | [standalone]


#34025

FromMinh Dang <dangbaminh.it@gmail.com>
Date2012-11-28 07:27 -0800
Message-ID<b63e29a3-02d3-4d77-94e6-3f1f73d18b71@googlegroups.com>
In reply to#34022
there are still these 2 problems and i don't know how to solve it

[toc] | [prev] | [next] | [standalone]


#34026

FromMinh Dang <dangbaminh.it@gmail.com>
Date2012-11-28 07:27 -0800
Message-ID<mailman.338.1354116431.29569.python-list@python.org>
In reply to#34022
there are still these 2 problems and i don't know how to solve it

[toc] | [prev] | [next] | [standalone]


Page 1 of 2  [1] 2  Next page →

Back to top | Article view | comp.lang.python


csiph-web