osociety / network_tools

Networking Tools library which can help you discover open ports, devices on subnet and many other things.
https://pub.dev/packages/network_tools
BSD 3-Clause "New" or "Revised" License
45 stars 13 forks source link

Example crash on Windows #14

Closed guyluz11 closed 2 years ago

guyluz11 commented 2 years ago

Not working on Windows

Unhandled exception:
SocketException: Connection failed (OS Error: The requested address is not valid in its context.
, errno = 10049), address = 192.168.1.1, port = 0
#0      _NativeSocket.startConnect (dart:io-patch/socket_patch.dart:681:35)
#1      _NativeSocket.connect (dart:io-patch/socket_patch.dart:940:12)
#2      _RawSocket.connect (dart:io-patch/socket_patch.dart:1796:26)
#3      RawSocket.connect (dart:io-patch/socket_patch.dart:21:23)
#4      Socket._connect (dart:io-patch/socket_patch.dart:2019:22)
#5      Socket.connect (dart:io/socket.dart:770:21)
#6      PortScanner.connectToPort (package:network_tools/src/port_scanner.dart:131:37)
#7      PortScanner.customDiscover (package:network_tools/src/port_scanner.dart:75:28)
<asynchronous suspension>

Process finished with exit code 255

Tested with my home IP but posted with the example IP.

git-elliot commented 2 years ago

Address is hardcoded. Maybe we should take it as a command line argument.

guyluz11 commented 2 years ago

The problem is not that it is use the wrong address by default, but this is another issue that we should think what is the best way to solve it.

Did you test this package on Windows?.

git-elliot commented 2 years ago

It is not tested on windows. I guess startPort when set to 0 getting us into trouble.

guyluz11 commented 2 years ago

It is not tested on windows. I guess startPort when set to 0 getting us into trouble.

Correct, after changing start port in the example

https://github.com/git-elliot/network_tools/blob/f9c811e73833e86af2739a1680fcd3d6ba1e35ab/example/main.dart#L53

to 1 the program run on Windows.