Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
182 views
in Technique[技术] by (71.8m points)

android - Cannot Fix Server Socket Flutter Dart on Visiual Studio

How can i solve this error? I have loaded localhost but still getting same error. This is my code:

Future<void> connect() async {
  var server = await HttpServer.bind(InternetAddress.loopbackIPv4, 80);

  server.listen((request) async {
    // Check if the path is '/login'
    if (request.uri.path == '/login') {
      // Create OpenId instance with the current request.
      OpenId openId = OpenId(request);

      // Switch the mode
      switch (openId.mode) {
        // No mode is set
        case '':
          {
            //Redirect the user to the authUrl.
            request.response
              ..redirect(openId.authUrl())
              ..close();
            break;
          }
        // Authentication failed/cancelled.

Error:

E/flutter (16515): [ERROR:flutter/lib/ui/ui_dart state.cc(184)] Unhandled Exception: SocketException: Failed to create server socket (OS Error: Permission denied, errno = 13), address = 127.0.0.1, port = 80

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Lower port numbers like port 80 is usually restricted to only be used by program running as administrator. So the error you have tells you that port 80 is restricted by permissions.

Instead of running the application as administrator you can use a higher port number like 8080.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...