LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-02-2010, 10:26 AM   #1
xskycamefalling
Member
 
Registered: May 2009
Posts: 43

Rep: Reputation: 15
indentation error in python simple socket program


hi all i was recently building on a simple socket program i had written in python basically like a little chat client but i added a server_socket.close command to kill the server on disconnect and now im getting all sorts of indentation errors

Code:
 #! /usr/bin/python
  2 import socket
  3 server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  4 server_socket.bind(("localhost", 5000))
  5 server_socket.listen(5)
  6
  7 print "TCPServer Waiting for client on port 5000"
  8
  9 while 1:
 10    client_socket, address = server_socket.accept()
 11    print "I got a connection from ", address
 12    while 1:
 13       data = raw_input ( "SEND( TYPE q or Q to Quit):" )
 14       if (data == 'Q' or data == 'q'):
 15          client_socket.send (data)
 16          client_socket.close()
 17          server_socket.close()
 18          break
 19       else:
 20          client_socket.send(data)
 21          data = client_socket.recv(512)
 22          if ( data == 'q' or data == 'Q'):
 23             client_socket.close()
 24             server_socket.close()
 25             break
 26          else:
 27             print "RECIEVED:" , data
 28
thats the code i have first error i get is line 18
File "./server.py", line 18
break
^
IndentationError: unindent does not match any outer indentation level
 
Old 02-02-2010, 07:15 PM   #2
Berhanie
Senior Member
 
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,625

Rep: Reputation: 165Reputation: 165
worked for me. maybe you have some tabs in there. check with
Code:
cat -A server.py
also, received is misspelled.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple C program - error with float J_K9 Programming 2 10-24-2005 11:36 AM
Python: Need help making a simple program using arrays and loops Baix Programming 11 08-13-2005 11:26 PM
gconf error installing python program on mandriva Crazypiglady Linux - Software 2 08-09-2005 09:30 AM
A simple program on C++ for the linux with an error. Israfel2000 Programming 4 06-16-2004 06:25 PM
Error for a very simple C program pkashyap Linux - Newbie 2 03-11-2004 10:24 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:05 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration