Witam,
Mam problem z serwerem TCP/IP. Program jest uruchomiony na raspberry pi 3. Problem polega na tym że gdy RPi jest podłączone do routera kablem to wszystko śmiga jak należy, ale kiedy podłącze się po WIFI to jakby nie było go widać. Klient jest w C# na Windows10. Ping odpowiada prawidłowo. Proszę o jakąś podowiedź jak to rozwiązać :)
Kod z C#: http://pastebin.com/VNXrDtuF
Kod z Pythona:
#-*- coding: utf-8 -*-
import socket
import serial
ser = serial.Serial('/dev/ttyS0', 9600)
s=socket.socket()
host = ''
port = 5562
storedValue = ("Yo, what's up?")
def setupServer():
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print("Socket created.")
try:
s.bind((host, port))
except socket.error as msg:
print(msg)
print("Socket bind complete.")
return s
def setupConnection():
s.listen(1) #jedno połączenie na raz.
conn, address = s.accept()
print("Connected to: " + address[0] + ":" + str(address[1]))
return conn
def GET():
reply = storedValue
return reply
def REPEAT(dataMessage):
reply = dataMessage[1]
return reply
def dataTransfer(conn):
#Duża pętla /send/receives data
while True:
data = conn.recv(1024) #receive the data
data = data.decode('utf-8')
dataMessage = data.split(' ', 1)
command = dataMessage[0]
print(command)
if command == '1':
print("1")
reply = '1'
elif command == '0':
reply = '0'
elif command == '2':
reply = '2'
elif command == '3':
reply = '3'
elif command == '4':
reply = '4'
else:
reply = '0'
#print(reply)
ser.write(reply)
conn.sendall(str.encode(reply))
#print("Data has been sent!")
conn.sloce()
s = setupServer()
while True:
try:
conn = setupConnection()
dataTransfer(conn)
except:
break