The Connected UDP socket code – setup

To Test the connected UDP socket code on the same host system, we need to setup two distinct endpoints so that we can test the code on the same host system.

Check the interface by running the command “ifconfig” on the linux terminal. Part output on my test system is provided below. (Note – the name of the interface on another system might be different that what is shown below)

enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.5 netmask 255.255.255.0 broadcast 192.168.0.255
inet6 fe80::468e:9977:dde8:a5e5 prefixlen 64 scopeid 0x20<link>
ether 08:00:27:92:c5:dc txqueuelen 1000 (Ethernet)
RX packets 4051 bytes 2105083 (2.1 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1222 bytes 194249 (194.2 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

We create two virtual interfaces from the interface above by running the below command on the terminal one after the other.

ifconfig enp0s3:0 192.168.0.11

ifconfig enp0s3:1 192.168.0.14

The output running the above commands is provided below. Run the command “ifconfig” again on the terminal. In addition to my primary interface, i see two virtual interfaces created as below

enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.5 netmask 255.255.255.0 broadcast 192.168.0.255
inet6 fe80::468e:9977:dde8:a5e5 prefixlen 64 scopeid 0x20<link>
ether 08:00:27:92:c5:dc txqueuelen 1000 (Ethernet)
RX packets 4073 bytes 2106838 (2.1 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1258 bytes 198052 (198.0 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

enp0s3:0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.11 netmask 255.255.255.0 broadcast 192.168.0.255
ether 08:00:27:92:c5:dc txqueuelen 1000 (Ethernet)

enp0s3:1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.14 netmask 255.255.255.0 broadcast 192.168.0.255
ether 08:00:27:92:c5:dc txqueuelen 1000 (Ethernet)

Now the two endpoints for the UDP connected socket code is ready and we try to run the server/client code (probably better to call it endpoint 1 – endpoint 2 code).

The Connected UDP Socket Code Example

Comments

  1. Pingback: The Connected UDP Socket connection | Hitch Hiker's Guide to Learning

  2. Pingback: Analyzing the connected UDP Socket code example | Hitch Hiker's Guide to Learning

Leave a Reply

Your email address will not be published. Required fields are marked *