Code Monkey home page Code Monkey logo

Comments (8)

wqweto avatar wqweto commented on June 18, 2024

Yes, this is a regression. I'll see to it some time when I get back in front of my PC next week.

from vbasyncsocket.

dragokas avatar dragokas commented on June 18, 2024

Thanks a much for your time to fix ip. That works now.
I have several questions about it, if you don't mind.

Sorry, if they are too noob-like.

Following image demonstrates sending packets from host to guest VM and vice versa (that is a previous patch w/o port fix yet):
socket_error

Host:
ip - 192.168.31.4
gateway - 192.168.31.1

VM:
ip - 192.168.202.169
gateway - 192.168.202.1

  1. When I listen on "localhost" or "127.0.0.1" (no matter VM, or host) I cannot send a packet - saying "cannot connect ..."
    Is it a normal behaviour? The only way to receive a packet between network interfaces is to set the listener on current ip (192.168.31.4 (host) or 192.168.202.169 (vm)).

  2. Listener (on host) said that the packet came from 192.168.31.4 which is its own ip! That is not correct since I sent it from vm.
    Vice versa. Litener on VM said that the packet came from 192.168.202.1 which is its gateway =)
    Maybe it is some specific behind inter-network interfaces transferring mechanism, so packet is losing info about its original sender...

  3. Another case. Maybe you could suggest how correctly open port to see it externally from Internet and be able to send packets?

  • I made port forwarding on 8088 in my router.
  • I added inbound and outbound rule for Listener application to my windows firewall.
  • I set listener on "localhost" with that port.
    Now I connected via RDP to another physical machine out of my local network to test is my port 8088 opened,
    e.g. site: https://www.yougetsignal.com/tools/open-ports/
    however, it shows me that the port is closed. Surely, this powershell command also failed:
Test-NetConnection my.external.ip.address -Port 8088
  • Also, I tried to set Listener on "my.external.ip.address" instead of "localhost", but such operation failed with runtime error: "Required address is incorrect for its context".

Very appreciate your answers, when you have time.

from vbasyncsocket.

wqweto avatar wqweto commented on June 18, 2024

When I listen on "localhost" or "127.0.0.1" (no matter VM, or host) I cannot send a packet - saying "cannot connect ..."

Try listen on 0.0.0.0. This will listen both on localhost and all other assigned local IPs.

. . . said that the packet came from 192.168.31.4 which is its own ip

Is this VirtualBox? (No, I see it's VMWare now.) It uses NAT for VM networks by default. Try setting network to bridged and assign IP from your real LAN card subnet.

. . . made port forwarding on 8088 in my router.

If your VM is bridged it has "real" IP from your LAN subnet so you can forward directly to it. If forwarding is not working to your real machine probably listener was setup incorrectly on 127.0.0.1.

When you start listener on 0.0.0.0 the Windows Firewall will popup a dialog suggesting to add your application to firewall inbound rules. This will be an indication your listener is setup correct :-))

from vbasyncsocket.

dragokas avatar dragokas commented on June 18, 2024

Lot of thanks for your detailed explanations! They was very helpful. Everything works.

One question: by design, when we are listening for a "localhost" only "preferred" network interface is catched.
What if we have 2 local network interfaces, but I want to listen for that second localhost interface (without 0.0.0.0, so a port should be invisible to the world). Is it possible?

from vbasyncsocket.

wqweto avatar wqweto commented on June 18, 2024

You have to listen to a specific local IP address that is assigned to this second LAN adapter.

Since commit 186a4dd you can use GetLocalHost method to retrieve an array with all local IPs as returned from GetAdaptersInfo API.

I can tweak it to return more info like network name or default gateway address, not only IP and subnet mask as currently impl.

from vbasyncsocket.

dragokas avatar dragokas commented on June 18, 2024

Is there a method to pass the whole array of IPs (subnet) from the second adapter to listen for?

from vbasyncsocket.

wqweto avatar wqweto commented on June 18, 2024

No, you can either bind a socket on 0.0.0.0 (so called INADDR_ANY to listen on all local IPs) or bind it to a single local IP address.

127.0.0.1 is the IP address of the local loopback adapter but so is 127.0.0.2 and every other address in 255.0.0.0 subnet so you can listen on (and connect to) all these addresses too.

from vbasyncsocket.

dragokas avatar dragokas commented on June 18, 2024

Ok, thank you.
I was thinking about trick to temporarily make second adapter to be preferred, then server.Listen "localhost", than return first adapter to be "preferred". Not sure, can it work that way =) Perhaps better just listen for 0.0.0.0 and use firewall to restrict external access to a port.

from vbasyncsocket.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.