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

Categories

0 votes
179 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 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...