Zord13appdesa / python-for-android

Automatically exported from code.google.com/p/python-for-android
Apache License 2.0
0 stars 0 forks source link

Cannot use sockets #49

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What device(s) are you experiencing the problem on? Cruz reader 

What firmware version are you running on the device? 2.1

What steps will reproduce the problem?
1.Write a script using Python on sl4a that connects to your computer
2.Write a Python script that has binds a socket
3.Run the programs and the android tablet times out without connecting.

What is the expected output? What do you see instead?
Expected output is a connection and a test message from the sockets. Instead a 
got a connection timed out error.

What version of the product are you using? On what operating system?
SL4A on Android 2.1

Please provide any additional information below.

Original issue reported on code.google.com by J.Rhynor...@gmail.com on 8 May 2012 at 9:36

GoogleCodeExporter commented 9 years ago
a) Sockets do work and have been tested. However, built-in firewalls will 
prevent you from binding to sockets below 1024. Please supply some example code.

b) This is a python question, not an sl4a question.

Original comment by rjmatthews62 on 8 May 2012 at 11:53

GoogleCodeExporter commented 9 years ago
server (On the computer)
[code]
import socket
s = socket.socket()
s.bind(("192.168.56.1", 12345))
s.listen(1)
while True:
c, addr = s.accept()
c.send("test")
c.close()
print "done"
[/code]

Client (On android device)
[code]
import android
import socket
d = android.Android()
s = socket.socket()
s.connect(("192.168.56.1", 12345))
print s.recv(1024)
[/code]

Any idea on why this isn't working on my device?

Original comment by J.Rhynor...@gmail.com on 9 May 2012 at 12:35

GoogleCodeExporter commented 9 years ago
Has there been any advancement in this code?

Original comment by J.Rhynor...@gmail.com on 17 May 2012 at 2:42

GoogleCodeExporter commented 9 years ago
I found some interesting information today. When I run the following code, it 
prints "True". Hope this will help in some way!

import socket
import android
d = android.Android()
s = socket.socket()
s.connect(("google.com", 80))
print True

Original comment by J.Rhynor...@gmail.com on 17 May 2012 at 6:24

GoogleCodeExporter commented 9 years ago
It has been tested and found to work, on several platforms.
Unless others can duplicate the problem, I have to assume it is something to do 
with the original poster's network setup.
There is a lengthy thread on this in the discussion list.
If others have problem, please check your desktop firewall settings. Also, 
network settings (some routers implement firewalls of their own.)

Original comment by rjmatthews62 on 17 May 2012 at 11:42