Python Forum
Thread Rating:
  • 2 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Flask Chat
#1
https://paste.ubuntu.com/p/wPwN84dwM5/

from flask import Flask, redirect, url_for, request, render_template
import settings

s=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
app = Flask(__name__)
host=socket.gethostbyname(socket.gethostname())
port=8080
s.bind((host,port)) 


def receivedata():
    while True:
        data, addr = s.recvfrom(1024)
        print(data.decode())
        print(addr)
   
   
@app.route("/", methods=['POST', 'GET'])
def home():
    if request.method == 'POST':
        return render_template('home.html')
    else:
        receivedata()
        return render_template('home.html')


app.run(debug=True)
Above the code If I call only receivedata function it works but when I try to work with flask and add flask code I take this error. I have no idea why. Error is " normally only one use is allowed for each socket address". How can I fix this error?
Reply


Messages In This Thread
Flask Chat - by Ahmet - Jul-09-2018, 06:34 AM
RE: Flask Chat - by micseydel - Jul-09-2018, 08:51 PM
RE: Flask Chat - by Ahmet - Jul-10-2018, 06:45 AM
RE: Flask Chat - by micseydel - Jul-10-2018, 04:39 PM
Flask Chat - by Ahmet - Jul-09-2018, 07:49 PM
RE: Flask Chat - by Larz60+ - Jul-09-2018, 07:51 PM
RE: Flask Chat - by Ahmet - Jul-09-2018, 08:01 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  chat system x64 2 3,916 Mar-15-2017, 06:59 AM
Last Post: charlesprince

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020