socket module OSError: 28

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
sidisgood
Posts: 1
Joined: Mon Sep 11, 2017 8:06 am

socket module OSError: 28

Post by sidisgood » Sun Sep 24, 2017 7:46 pm

Hello MicroPython community,

Just playing with socket module using esp8266, I wrote a little script to transfer file from computer to esp board and I faced a problem. So as I understood here is the problem to write binary to a file, the error appears:

Traceback (most recent call last):
File "<stdin>", line 27, in <module>
File "<stdin>", line 23, in start_deamon
File "<stdin>", line 23, in start_deamon
OSError: 28

and here is my code:

server side will listen and receive the file

import socket
import sys

localhost = ("0.0.0.0", 37641)

def start_deamon():

s = socket.socket(socket.AF_INET,
socket.SOCK_STREAM)

s.setsockopt(socket.SOL_SOCKET,
socket.SO_REUSEADDR, 1)

s.bind(localhost)
s.listen(5) # allow listening

while True:
conn, addr = s.accept()
print('Got connection from', addr)
data = conn.recv(1024)

with open('received_file', 'wb') as f:
f.write(data)
f.close()
s.close()

start_deamon()

and client will send file

#!/usr/bin/env python3

import socket
import sys

remotehost = ("192.168.1.194", 37641)

def file_transfer():
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.connect(remotehost)

f = open(sys.argv[1], 'rb')
data = f.read(1024)
s.sendall(data)
f.close()
s.close()

if __name__ == "__main__":
file_transfer()

Here is simple file transfer script, tried to find the solution in off sources but no luck to solve it, so if some one could help me I would really appreciate. Thank you in advance!

P.S. sorry BBCode is off and i can't do anything with that.

Post Reply