Re: [android-developers] Re: Connection between Android phone and python server suggestion
You can use a socket on android, although you must be a client for it to work reliably. You cannot and should not act as a server on the android side. To use a socket, simply connect to the ip of the server you are trying to connect to. On Tue, May 17, 2011 at 1:04 PM, ingy abbas ingy.abba...@gmail.com wrote: what about socket ..it is not connected What ip address i must put ?!!! On 17 مايو, 19:16, Nicholas Johnson metthejohn...@gmail.com wrote: Yes, it can be done. You can exchange data between a server and an Android app in any way that you want. I prefer encoding the communication/data in a JSON object. Nick -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- ~ Jeremiah:9:23-24 Android 2D MMORPG: http://solrpg.com/, http://www.youtube.com/user/revoltingx -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Connection between Android phone and python server suggestion
You should post your socket code, or provide more information. On Tue, May 17, 2011 at 2:14 PM, ingy abbas ingy.abba...@gmail.com wrote: This what i did and it connect only when i'm using the android emulator but when i use the mobile it did not connect !!any help in this On 17 مايو, 22:42, Nicholas Johnson metthejohn...@gmail.com wrote: Put the IP address of the server you're trying to connect to. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- ~ Jeremiah:9:23-24 Android 2D MMORPG: http://solrpg.com/, http://www.youtube.com/user/revoltingx -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Connection between Android phone and python server suggestion
On 05/17/2011 02:14 PM, ingy abbas wrote: This what i did and it connect only when i'm using the android emulator but when i use the mobile it did not connect !!any help in this Can you browse the web on the mobile? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Connection between Android phone and python server suggestion
Just post the code to pastebin and show it here. The more eyes, the better. On Tue, May 17, 2011 at 2:27 PM, ingy abbas ingy.abba...@gmail.com wrote: Sure becaue i;m using wifi so it open a web page On 17 مايو, 23:21, Tobiah t...@tobiah.org wrote: On 05/17/2011 02:14 PM, ingy abbas wrote: This what i did and it connect only when i'm using the android emulator but when i use the mobile it did not connect !!any help in this Can you browse the web on the mobile? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- ~ Jeremiah:9:23-24 Android 2D MMORPG: http://solrpg.com/, http://www.youtube.com/user/revoltingx -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Connection between Android phone and python server suggestion
If your server works fine using the emulator as your client it seems like it's a networking issue, and not a code issue. BTW, DON'T mix network code and UI code. Read: http://developer.android.com/resources/articles/painless-threading.html On Tue, May 17, 2011 at 3:10 PM, ingy abbas ingy.abba...@gmail.com wrote: import sys from threading import Thread import socket import MySQLdb allClients=[] class Client(Thread): 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 (i2): 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 ) def run(self): self.newClientConnect() 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 = '50.0.10.107' 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(('',54633)) except ValueError,e: print e serversocket.listen(5) db= MySQLdb.connect(host= localhost, user=root, passwd=newpassword, db=new_schema) cursor = db.cursor() sql=CREATE TABLE try (COL1 VARCHAR(45), COL2 VARCHAR(45), PRIMARY KEY (COL1)) cursor.execute(sql) #insert to table cursor.execute(INSERT INTO try VALUES (%s,%s),(opa,myghost)) db.commit() #db.rollback() #show table #cursor.execute(SELECT * FROM try) print cursor.fetchall() db.close() print Connected to the Database while True: (clientSocket, address) = serversocket.accept() print 'New connection from ', address ct = Client(clientSocket) ct.start() __all__ = ['allClients','Client'] -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- ~ Jeremiah:9:23-24 Android 2D MMORPG: http://solrpg.com/, http://www.youtube.com/user/revoltingx -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Connection between Android phone and python server suggestion
Make sure your port is open so that outside clients can connect to that port. First, go to a computer outside your network and try to run: telnet 50.0.10.107 54639 When that succeeds, you can continue. On Tue, May 17, 2011 at 3:12 PM, ingy abbas ingy.abba...@gmail.com wrote: so how can i make the server connect to the Mobile the code is working and connect on the emulator putting same port and localhost On May 18, 12:08 am, Miguel Morales therevolti...@gmail.com wrote: I can't seem to telnet using the following command: telnet 50.0.10.107 54639 Make sure your server has that port open, perhaps it works in the emulator because the emulator and server are on the same machine. On Tue, May 17, 2011 at 3:02 PM, ingy abbas ingy.abba...@gmail.com wrote: package tryanabtry.opa; import java.io.BufferedReader; import java.io.DataOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.net.DatagramPacket; import java.net.DatagramSocket; import java.net.InetSocketAddress; import java.net.Socket; import java.net.SocketException; import java.util.List; import android.app.PendingIntent; import android.content.Context; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Point; import android.graphics.drawable.Drawable; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.os.Handler; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.TextView; import android.widget.Toast; import com.google.android.maps.GeoPoint; import com.google.android.maps.MapActivity; import com.google.android.maps.MapController; import com.google.android.maps.MapView; import com.google.android.maps.Overlay; import com.google.android.maps.OverlayItem; public class tryanabtry extends MapActivity { Socket clientSocket; TextView Text; private MapView mapView; private MapController mc; DataOutputStream outToServer; BufferedReader inFromServer ; int error = 100; GeoPoint p, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13,p14,p15,p16,p17,p18,p19,p20,p21,p22,p23,p24,p25,p26,p27,p28,p29; ListOverlay mapOverlays; Drawable drawable, drawable2, drawable3, drawable4, drawable6, drawable7, drawable8, drawable9, drawable10, drawable11, drawable12, drawable13, drawable5, drawable14, drawable15, drawable16, drawable17, drawable18, drawable19, drawable20, drawable21, drawable22, drawable23, drawable24, drawable25, drawable26, drawable27, drawable28, drawable29; HelloItemizedOverlay itemizedOverlay, itemizedOverlay2, itemizedOverlay3, itemizedOverlay4, itemizedOverlay5, itemizedOverlay6, itemizedOverlay7, itemizedOverlay8, itemizedOverlay9, itemizedOverlay10, itemizedOverlay11, itemizedOverlay12, itemizedOverlay13, itemizedOverlay14, itemizedOverlay15, itemizedOverlay16, itemizedOverlay17, itemizedOverlay18, itemizedOverlay19, itemizedOverlay20, itemizedOverlay21, itemizedOverlay22, itemizedOverlay23, itemizedOverlay24, itemizedOverlay25, itemizedOverlay26, itemizedOverlay27, itemizedOverlay28, itemizedOverlay29; LocationManager locationManager; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { try { super.onCreate(savedInstanceState); setContentView(R.layout.main); /* Use the LocationManager class to obtain GPS locations */ LocationManager mlocManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); LocationListener mlocListener = new MyLocationListener(); mlocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, mlocListener); mapView = (MapView) findViewById(R.id.mapView); // enable Street view by default mapView.setStreetView(true); // enable to show Satellite view mapView.setSatellite(true); // enable to show Traffic on map // mapView.setTraffic(true); mapView.setBuiltInZoomControls(true); mc = mapView.getController();
Re: [android-developers] Re: Connection between Android phone and python server suggestion
And you tried it from a different computer, right? Not one in your house/office? It does not work from here. On Tue, May 17, 2011 at 3:45 PM, ingy abbas ingy.abba...@gmail.com wrote: its open microsoft telnet command but the 50.0.10.107 54639 Microsoft Telnet 50.0.10.107 54639 Invalid Command. type ?/help for help On May 18, 12:15 am, Miguel Morales therevolti...@gmail.com wrote: Make sure your port is open so that outside clients can connect to that port. First, go to a computer outside your network and try to run: telnet 50.0.10.107 54639 When that succeeds, you can continue. On Tue, May 17, 2011 at 3:12 PM, ingy abbas ingy.abba...@gmail.com wrote: so how can i make the server connect to the Mobile the code is working and connect on the emulator putting same port and localhost On May 18, 12:08 am, Miguel Morales therevolti...@gmail.com wrote: I can't seem to telnet using the following command: telnet 50.0.10.107 54639 Make sure your server has that port open, perhaps it works in the emulator because the emulator and server are on the same machine. On Tue, May 17, 2011 at 3:02 PM, ingy abbas ingy.abba...@gmail.com wrote: package tryanabtry.opa; import java.io.BufferedReader; import java.io.DataOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.net.DatagramPacket; import java.net.DatagramSocket; import java.net.InetSocketAddress; import java.net.Socket; import java.net.SocketException; import java.util.List; import android.app.PendingIntent; import android.content.Context; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Point; import android.graphics.drawable.Drawable; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.os.Handler; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.TextView; import android.widget.Toast; import com.google.android.maps.GeoPoint; import com.google.android.maps.MapActivity; import com.google.android.maps.MapController; import com.google.android.maps.MapView; import com.google.android.maps.Overlay; import com.google.android.maps.OverlayItem; public class tryanabtry extends MapActivity { Socket clientSocket; TextView Text; private MapView mapView; private MapController mc; DataOutputStream outToServer; BufferedReader inFromServer ; int error = 100; GeoPoint p, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13,p14,p15,p16,p17,p18,p19,p20,p21,p22,p23,p24,p25,p26,p27,p28,p29; ListOverlay mapOverlays; Drawable drawable, drawable2, drawable3, drawable4, drawable6, drawable7, drawable8, drawable9, drawable10, drawable11, drawable12, drawable13, drawable5, drawable14, drawable15, drawable16, drawable17, drawable18, drawable19, drawable20, drawable21, drawable22, drawable23, drawable24, drawable25, drawable26, drawable27, drawable28, drawable29; HelloItemizedOverlay itemizedOverlay, itemizedOverlay2, itemizedOverlay3, itemizedOverlay4, itemizedOverlay5, itemizedOverlay6, itemizedOverlay7, itemizedOverlay8, itemizedOverlay9, itemizedOverlay10, itemizedOverlay11, itemizedOverlay12, itemizedOverlay13, itemizedOverlay14, itemizedOverlay15, itemizedOverlay16, itemizedOverlay17, itemizedOverlay18, itemizedOverlay19, itemizedOverlay20, itemizedOverlay21, itemizedOverlay22, itemizedOverlay23, itemizedOverlay24, itemizedOverlay25, itemizedOverlay26, itemizedOverlay27, itemizedOverlay28, itemizedOverlay29; LocationManager locationManager; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { try { super.onCreate(savedInstanceState); setContentView(R.layout.main); /* Use the LocationManager class to obtain GPS locations */ LocationManager mlocManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); LocationListener mlocListener = new MyLocationListener(); mlocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0,
Re: [android-developers] Re: Connection between Android phone and python server suggestion
I don't know what to tell you. Go to another house, or an internet cafe and try the command there. Like I said, my computer cannot connect, so it's a firewall/network issue. On Tue, May 17, 2011 at 3:59 PM, ingy abbas ingy.abba...@gmail.com wrote: yup in computers it work but in mobile Not !! and its a huge problem due to my project so do you have any suggestion On May 18, 12:47 am, Miguel Morales therevolti...@gmail.com wrote: And you tried it from a different computer, right? Not one in your house/office? It does not work from here. On Tue, May 17, 2011 at 3:45 PM, ingy abbas ingy.abba...@gmail.com wrote: its open microsoft telnet command but the 50.0.10.107 54639 Microsoft Telnet 50.0.10.107 54639 Invalid Command. type ?/help for help On May 18, 12:15 am, Miguel Morales therevolti...@gmail.com wrote: Make sure your port is open so that outside clients can connect to that port. First, go to a computer outside your network and try to run: telnet 50.0.10.107 54639 When that succeeds, you can continue. On Tue, May 17, 2011 at 3:12 PM, ingy abbas ingy.abba...@gmail.com wrote: so how can i make the server connect to the Mobile the code is working and connect on the emulator putting same port and localhost On May 18, 12:08 am, Miguel Morales therevolti...@gmail.com wrote: I can't seem to telnet using the following command: telnet 50.0.10.107 54639 Make sure your server has that port open, perhaps it works in the emulator because the emulator and server are on the same machine. On Tue, May 17, 2011 at 3:02 PM, ingy abbas ingy.abba...@gmail.com wrote: package tryanabtry.opa; import java.io.BufferedReader; import java.io.DataOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.net.DatagramPacket; import java.net.DatagramSocket; import java.net.InetSocketAddress; import java.net.Socket; import java.net.SocketException; import java.util.List; import android.app.PendingIntent; import android.content.Context; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Point; import android.graphics.drawable.Drawable; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.os.Handler; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.TextView; import android.widget.Toast; import com.google.android.maps.GeoPoint; import com.google.android.maps.MapActivity; import com.google.android.maps.MapController; import com.google.android.maps.MapView; import com.google.android.maps.Overlay; import com.google.android.maps.OverlayItem; public class tryanabtry extends MapActivity { Socket clientSocket; TextView Text; private MapView mapView; private MapController mc; DataOutputStream outToServer; BufferedReader inFromServer ; int error = 100; GeoPoint p, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13,p14,p15,p16,p17,p18,p19,p20,p21,p22,p23,p24,p25,p26,p27,p28,p29; ListOverlay mapOverlays; Drawable drawable, drawable2, drawable3, drawable4, drawable6, drawable7, drawable8, drawable9, drawable10, drawable11, drawable12, drawable13, drawable5, drawable14, drawable15, drawable16, drawable17, drawable18, drawable19, drawable20, drawable21, drawable22, drawable23, drawable24, drawable25, drawable26, drawable27, drawable28, drawable29; HelloItemizedOverlay itemizedOverlay, itemizedOverlay2, itemizedOverlay3, itemizedOverlay4, itemizedOverlay5, itemizedOverlay6, itemizedOverlay7, itemizedOverlay8, itemizedOverlay9, itemizedOverlay10, itemizedOverlay11, itemizedOverlay12, itemizedOverlay13, itemizedOverlay14, itemizedOverlay15, itemizedOverlay16, itemizedOverlay17, itemizedOverlay18, itemizedOverlay19, itemizedOverlay20, itemizedOverlay21, itemizedOverlay22, itemizedOverlay23, itemizedOverlay24, itemizedOverlay25, itemizedOverlay26, itemizedOverlay27, itemizedOverlay28, itemizedOverlay29; LocationManager locationManager; /** Called when the activity is first created.
Re: [android-developers] Re: Connection between Android phone and python server suggestion
Yep: telnet 50.0.10.107 54639 (all in one line of course) Also, it can't be just ANY port. It has to be the port in which your server is listening to. On Tue, May 17, 2011 at 4:05 PM, ingy abbas ingy.abba...@gmail.com wrote: telnet 50.0.10.107 54639 and the 50.0.10.107 must be the pc IP and any port right ??? On May 18, 1:00 am, Miguel Morales therevolti...@gmail.com wrote: I don't know what to tell you. Go to another house, or an internet cafe and try the command there. Like I said, my computer cannot connect, so it's a firewall/network issue. On Tue, May 17, 2011 at 3:59 PM, ingy abbas ingy.abba...@gmail.com wrote: yup in computers it work but in mobile Not !! and its a huge problem due to my project so do you have any suggestion On May 18, 12:47 am, Miguel Morales therevolti...@gmail.com wrote: And you tried it from a different computer, right? Not one in your house/office? It does not work from here. On Tue, May 17, 2011 at 3:45 PM, ingy abbas ingy.abba...@gmail.com wrote: its open microsoft telnet command but the 50.0.10.107 54639 Microsoft Telnet 50.0.10.107 54639 Invalid Command. type ?/help for help On May 18, 12:15 am, Miguel Morales therevolti...@gmail.com wrote: Make sure your port is open so that outside clients can connect to that port. First, go to a computer outside your network and try to run: telnet 50.0.10.107 54639 When that succeeds, you can continue. On Tue, May 17, 2011 at 3:12 PM, ingy abbas ingy.abba...@gmail.com wrote: so how can i make the server connect to the Mobile the code is working and connect on the emulator putting same port and localhost On May 18, 12:08 am, Miguel Morales therevolti...@gmail.com wrote: I can't seem to telnet using the following command: telnet 50.0.10.107 54639 Make sure your server has that port open, perhaps it works in the emulator because the emulator and server are on the same machine. On Tue, May 17, 2011 at 3:02 PM, ingy abbas ingy.abba...@gmail.com wrote: package tryanabtry.opa; import java.io.BufferedReader; import java.io.DataOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.net.DatagramPacket; import java.net.DatagramSocket; import java.net.InetSocketAddress; import java.net.Socket; import java.net.SocketException; import java.util.List; import android.app.PendingIntent; import android.content.Context; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Point; import android.graphics.drawable.Drawable; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.os.Handler; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.TextView; import android.widget.Toast; import com.google.android.maps.GeoPoint; import com.google.android.maps.MapActivity; import com.google.android.maps.MapController; import com.google.android.maps.MapView; import com.google.android.maps.Overlay; import com.google.android.maps.OverlayItem; public class tryanabtry extends MapActivity { Socket clientSocket; TextView Text; private MapView mapView; private MapController mc; DataOutputStream outToServer; BufferedReader inFromServer ; int error = 100; GeoPoint p, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13,p14,p15,p16,p17,p18,p19,p20,p21,p22,p23,p24,p25,p26,p27,p28,p29; ListOverlay mapOverlays; Drawable drawable, drawable2, drawable3, drawable4, drawable6, drawable7, drawable8, drawable9, drawable10, drawable11, drawable12, drawable13, drawable5, drawable14, drawable15, drawable16, drawable17, drawable18, drawable19, drawable20, drawable21, drawable22, drawable23, drawable24, drawable25, drawable26, drawable27, drawable28, drawable29; HelloItemizedOverlay itemizedOverlay, itemizedOverlay2, itemizedOverlay3, itemizedOverlay4, itemizedOverlay5, itemizedOverlay6, itemizedOverlay7, itemizedOverlay8,