See wget: https://raspberry-projects.com/pi/command-line/wget/wget-general
Category: TCP/IP
Check interface connection and trigger reconnect
If WiFi is lost raspbian doesn't seem to currently reconnect if an access point is available again. You need to setup a script to check it and cause it to be reset if it has dropped out. See here. C Code To Check Connection Status & Trigger Reconnect Of Dropped WiFi Interface #define TCPIP_INTERFACE_RESET_SECONDS_TIME (5 * 60) //If interface is […]
Sockets – General
Good C/C++ Resources For Programming Sockets Beej's Guide to Network Programming << Great resource
Configuring Network Adaptors
Editing Network Adaptor Settings Restarting After Changes After changes to the network interface configuration, you have to restart the network interface using this (assuming the interface is called “eth0”). sudo ip link set eth0 down && sudo ip link set eth0 up Assigning A Manual IP Address For recent versions of Raspbian /etc/network/interfaces should no longer be […]
.General PHP Code Tricks
Issuing Commands From Web Pages If you install a PHP web server on your RPi you can issue commands using the PHP system() function. Examples: //Echo some system status: echo '<pre>'; system('netstat -a'); echo '</pre>'; //Run an executable file: echo '<pre>'; system("sudo /home/pi/projects/my_project.a"); //system() will echo the output of the executable, use shell_exec() instead if […]
Network Interface Code Snippets
These are bits of code we've found for linux that don't necessarily relate exactly to raspbian on the RPi, but may be useful Network Config //Code sourced from: http://www.network-builders.com/programatically-change-ip-address-t58439.html //The RPi doesn't have a folder "/etc/sysconfig/" so this isn't usable as currently implemented #include <stdio.h> #include <errno.h> #include <stdlib.h> #include <string.h> #include <sys/ioctl.h> #include […]
Read Local Network Adaptors
Get IP Address and Sunet Mask Of Each Network Interface #include <stdio.h> #include <sys/types.h> #include <ifaddrs.h> #include <netinet/in.h> #include <string.h> #include <arpa/inet.h> #define MAX_NETWORK_ADAPTORS 3 #define MAX_ADAPTOR_NAME_LENGTH 20 BYTE found_network_adaptors_count; char NetworkAdaptorName[MAX_NETWORK_ADAPTORS][MAX_ADAPTOR_NAME_LENGTH]; char NetworkAdaptorIpAddress[MAX_NETWORK_ADAPTORS][INET_ADDRSTRLEN]; char NetworkAdaptorSubnetMask[MAX_NETWORK_ADAPTORS][INET_ADDRSTRLEN]; //*************************************************** //*************************************************** //********** READ NETWORK ADAPTOR SETTINGS ********** //*************************************************** //*************************************************** void network_read_network_adaptor_settings (void) { struct ifaddrs * ifAddrStruct = […]