OSError: [Errno 98] EADDRINUSE #10438
Replies: 3 comments 5 replies
-
|
Beta Was this translation helpful? Give feedback.
-
thanks for the answer, i find the solution in the meantime, it was connection.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) nearly the same as your solution. |
Beta Was this translation helpful? Give feedback.
-
Answer ! of this link https://stackoverflow.com/questions/6380057/address-already-in-use-error-when-binding-a-socket-in-python Worked but not sure if setting the port to 0 is a good idea in the address, but it let me run a test adding connection.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) alone was still gave OSError: [Errno 98] EADDRINUSE when address = (ip, 80) is in the code. |
Beta Was this translation helpful? Give feedback.
-
Hi, i am a beginner, and done the code on https://projects.raspberrypi.org/en/projects/get-started-pico-w/5
at first all went fine, then i get this error and dont no why?!
Traceback (most recent call last):
File "", line 35, in
File "", line 29, in open_socket
OSError: [Errno 98] EADDRINUSE
import network
import socket
from time import sleep
from picozero import pico_temp_sensor, pico_led
import machine
ssid = 'OpenWrt'
password = '**********'
def connect():
#Connect to WLAN
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect(ssid, password)
while wlan.isconnected() == False:
print('Waiting for connection...')
sleep(1)
ip = wlan.ifconfig()[0]
print(f'Connected on {ip}')
return ip
def open_socket(ip):
# Open a socket
address = (ip, 80)
connection = socket.socket()
connection.bind(address)
connection.listen(1)
return connection
try:
ip = connect()
open_socket(ip)
except KeyboardInterrupt:
machine.reset()
Beta Was this translation helpful? Give feedback.
All reactions