This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: python on raspberry pi
Type: Stage: resolved
Components: Build Versions:
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: eric.smith, gyenoti, steven.daprano
Priority: normal Keywords:

Created on 2021-03-16 15:50 by gyenoti, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg388850 - (view) Author: Yann Enoti (gyenoti) Date: 2021-03-16 15:50
Any idea why this doesnt work ?


import socket

HOST = "192.168.2.114"
PORT = 8000 #initiate port no above 1024

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print('Socket created')

#try:
s.bind((HOST, PORT))  #bind host address and port together#
#except socket.error as e:
    #print('Bind failed.')
    
s.listen(10)  #configure how many clients the server can listen to simultaneously

print("Socket is Listening")
 
#conn, addr = s.accept()    #accept new connection
#print("connection from:" + str(addr))
    

while True:
    conn, addr = s.accept()    #accept new connection
    print("connection from:" + str(addr))
    
    data = conn.recv(1024).decode()  #receive data stream
    
    #if not data: #if data is not received break
           # break
    print("from Android App:" + str(data))
    data = input ('from Python Server:')
    conn.send(data.encode())  #send data to client
    conn.close()  #close the connection
msg388853 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2021-03-16 16:10
You’ve not told us the behavior you see or the behavior you expect, so we can’t tell if this is a bug in python. 

But it’s in all likelihood not a bug. If you want to get help with your code, I suggest asking on the python-list mailing list or maybe Stackoverflow. This bug tracker is not a support forum. 

https://mail.python.org/mailman/listinfo/python-list
msg388897 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2021-03-16 23:56
Yann,

Eric is correct -- this isn't a help desk. Please ask your question on one of the many forums available for asking help, but before you do, please read:

http://www.sscce.org/

https://stackoverflow.com/help/minimal-reproducible-example

and remember to let them know what you expected the code to do and what it did instead.

You'll also need to tell them the version of Python you are running, and clarify whether you are running on a Raspberry Pi (as the title says) or Android (as the code says).
History
Date User Action Args
2022-04-11 14:59:42adminsetgithub: 87682
2021-03-16 23:56:25steven.dapranosetstatus: pending -> closed

nosy: + steven.daprano
messages: + msg388897

resolution: not a bug
stage: resolved
2021-03-16 16:10:20eric.smithsetstatus: open -> pending
nosy: + eric.smith
messages: + msg388853

2021-03-16 15:50:02gyenoticreate