[ad_1]
I’m making an attempt to create a easy HttpServer in flutter. I’m growing on an apple silicone mac (MacOS Monterey).
I’m always getting the next error message (independently of the port I attempt to bind – and I do know that it isn’t at the moment binded):
SocketException (SocketException: Didn’t create server socket (OS Error: The shared flag to bind() must be
trueif binding a number of instances on the identical (deal with, port) mixture.), deal with = 127.0.0.1, port = 18006)
Anybody is aware of easy methods to repair this? It’s clear that the port shouldn’t be bind (any port will default to the identical exception!). Is that this yet another of the “protecting” options of MacOS Monterey?
Thanks!
Code instance:
class _HomeState extends State<House> {
String statusText = "Begin Server";
startServer() async {
setState(() {
statusText = "Beginning server on Port : 18034";
});
var server = await HttpServer.bind(InternetAddress.loopbackIPv4, 18006);
print("Server working on IP : " +
server.deal with.toString() +
" On Port : " +
server.port.toString());
await for (var request in server) {
request.response
..headers.contentType =
new ContentType("textual content", "plain", charset: "utf-8")
..write('Good day, world')
..shut();
}
setState(() {
statusText = "Server working on IP : " +
server.deal with.toString() +
" On Port : " +
server.port.toString();
});
}
[ad_2]
