stuck at this from so much time,need help....please ..
python at mrabarnett.plus.com
Sat Nov 23 23:58:27 CET 2013
On 23/11/2013 22:29, Bhanu Karthik wrote:> On Saturday, 23 November 2013
14:23:08 UTC-8, Chris Angelico wrote:
>> On Sun, Nov 24, 2013 at 9:15 AM, Bhanu Karthik
>> <bhanukarthik2002 at gmail.com> wrote:
>> > data = sock.recv(RECV_BUFFER)
>> > username = str(sock.getpeername())
>> > username = usernames[username]
>> > if command == "/quit":
>> > print data
>> > sock.send("bye")
>> > sock.close()
>> > CONNECTION_LIST.remove(sock)
>> > even if the received data is '/quit' the if condition not
>> At what point is command set? You're setting data here; is command
>> supposed to be derived from data?
>> This looks like a MUD or IRC style of server, which would suggest that
>> commands are terminated by end-of-line. You may need to take content
>> from the socket (currently in data) and split it off on either "\r\n"
>> or "\n". But it's hard to tell from this small snippet.
> sorry its not command its data....
> I miss wrote it here...
If the 'if' condition not executing then it must be because the
received data isn't "/quit", so what is it? Print it out, or, even
better, print out repr(data), which will show you any spaces or "\n" in
sock.recv(RECV_BUFFER) will receive up to RECV_BUFFER bytes, so if the
sender is sending other stuff after the "/quit" and RECV_BUFFER > 5,
then you might be receiving some of that later stuff too.
More information about the Python-list