send data to python server using mobile android
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/6144773/sending-a-string-of-lat-and-long-from-mobile-to-server">Sending A string of lat and long from mobile to server</a>  </p>
</blockquote>



<p>Why it created a socket between the mobile samsung glaxy and the server python  pc but can not send the data . what is wrong with this it just force close  </p>

<pre><code>enter code here
     public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    inputfld=(EditText)findViewById(R.id.input);
    Text=(TextView)findViewById(R.id.view);
    Enter=(Button)findViewById(R.id.enter);
    Connect=(Button)findViewById(R.id.connect);
     yaraby x=new yaraby();
    Text.append( "\n about to create a socket");    


    txt=(EditText)findViewById(R.id.txt);
    next = (Button) findViewById(R.id.Button01);   

    next.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            try{
            Intent i = new Intent(yaraby.this, yarab.class);
            startActivity(i);
            }
            catch(Error e){
                Log.e("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", e.getMessage());
            }
            Toast.makeText(getApplicationContext(), "haaaaaaaaaaa",Toast.LENGTH_LONG).show();
        }
    });

}

public void appendText(View view){
    Text.append( "\n  In chat ");

    try{

    sentence=inputfld.getText().toString();
    Text.append( "\n  DataStream creating");        
    outToServer.writeBytes(sentence);
    modifiedSentence = inFromServer.readLine(); 
    Text.append(modifiedSentence);
    inputfld.setText(null);

    }
    }
    catch(Exception modifiedsentence){
        Text.append("Exception");
    }


   }
</code></pre>

<p>Python server code</p>

<pre><code>enter code here
import sys
</code></pre>

<p>from threading import Thread
import socket
import MySQLdb</p>

<p>allClients=[]</p>

<p>class Client(Thread):</p>

<pre><code>def __init__(self,clientSocket):
            Thread.__init__(self)
            self.sockfd = clientSocket #socket client
            self.name = ""
            self.nickName = ""

def newClientConnect(self):

  allClients.append(self.sockfd)
  while True:


        while True:

            try:
                 rm= self.sockfd.recv(2048)
                 print rm
                 i=0

                 while (i&lt;2):

                    if   (rm) == row[i][0]:                   
                        reply="\n Welcome to our game %s: %s"%(rm,row[i][1])
                        self.sockfd.send(reply)
                        break

                    else:

                        i=i+1
                    if i==2:
                        reply="\n Error opaa ba2a"
                        self.sockfd.send(reply)
                        i=0
                        break
                 break

            except ValueError:
                   self.sockfd.send("\n UNVAlied Comment ")
            while True:
                    buff = self.sockfd.recv(2048)
                    if buff.strip() == 'quit':
                         self.sockfd.close()
                         break # Exit when break
                    else:
                         self.sendAll(buff)
     #Main
 if __name__ == "__main__":

#Server Connection to socket:
IP = "192.168.1.2"
PORT = 5807
serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
serversocket.setsockopt( socket.SOL_SOCKET, socket.SO_REUSEADDR, 1 )
print ("Server Started")
try:
    serversocket.bind(("192.168.1.3",54634))
except ValueError,e:
    print e
serversocket.listen(5)


db= MySQLdb.connect(host= "localhost",
              user="root",
              passwd="newpassword",
              db="new_schema")


  x=db.cursor()

 x.execute("SELECT *  FROM lolo")


   row = x.fetchall()


  print "Connected to the Database"

       ##################    #Server Waiting for any Clients:  
    while True:
    (clientSocket, address) = serversocket.accept()
    print 'New connection from ', address
    ct = Client(clientSocket)
    ct.start()




     __all__ = ['allClients','Client']
</code></pre>

<p>So what is wrong and i must solve it ?????</p>
