0

I am new to socket programming and have a couple of questions.

For the context, I have a server and client with each having a socket opened: the socket on the server is bounded to INADDR_ANY which from my understanding listens to connection requests from any network interface, and the socket on the client-side is connected to a loopback interface for the time being.

  1. With this config, client is connecting to the server through the loopback interface or? I'm trying to visualize how the client server connection is established and how is the client interface used in establishing a connection.

  2. I was able to send a message from the client to the server however I don't see a packet in the wireshark. That shouldn't be the case, no?

Jazzy
  • 101
  • 2

1 Answers1

0
  1. Yes, client uses the localhost interface to send packets to the server, provided that they are running on the same machine.

  2. The packet should be visible when you monitor the localhost interface with Wireshark.

Tero Kilkanen
  • 36,796
  • 3
  • 41
  • 63
  • 1. so basically any network interface could be used? also, what if the server is sitting elsewhere and the client wants to connect to it? 2. that's the thing though...I don't see any packet for 127.0.0.1 – Jazzy Jul 25 '21 at 07:18
  • If server listens to any interface, it can be reached via any interface, that is, from any network that is routed properly to the server. Are you sure you have selected localhost interface in Wireshark? – Tero Kilkanen Jul 25 '21 at 07:44
  • True. was making sure because you mentioned as long as server and client are on the same machine. And are you referring to a filter? I tried both: no filter and did a ctrl-f for the 127.0.0.1 IP to no avail and with filter `ip.addr==127.0.0.1` – Jazzy Jul 25 '21 at 08:01
  • No, I am referring to the interface selection in Wireshark. It is not a filter. – Tero Kilkanen Jul 25 '21 at 08:38
  • Is that a answer or a comment? – djdomi Jul 25 '21 at 12:52