Skip to content

Commit 1b5c2de

Browse files
Remove usage of deprecated string-based API
1 parent ccf2f48 commit 1b5c2de

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

main.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,13 @@ int main() {
3232
}
3333

3434
// Show the network address
35-
const char *ip = net->get_ip_address();
36-
const char *netmask = net->get_netmask();
37-
const char *gateway = net->get_gateway();
38-
printf("IP address: %s\n", ip ? ip : "None");
39-
printf("Netmask: %s\n", netmask ? netmask : "None");
40-
printf("Gateway: %s\n", gateway ? gateway : "None");
35+
SocketAddress a;
36+
net->get_ip_address(&a);
37+
printf("IP address: %s\n", a.get_ip_address() ? a.get_ip_address() : "None");
38+
net->get_netmask(&a);
39+
printf("Netmask: %s\n", a.get_ip_address() ? a.get_ip_address() : "None");
40+
net->get_gateway(&a);
41+
printf("Gateway: %s\n", a.get_ip_address() ? a.get_ip_address() : "None");
4142

4243
// Open a socket on the network interface, and create a TCP connection to ifconfig.io
4344
TCPSocket socket;

0 commit comments

Comments
 (0)