youyeetooRJ supports 1 Gigabit Ethernet port (Ethernet0)

linaro@linaro-alip:~$ ifconfig
eth0 Link encap:Ethernet HWaddr de:37:22:3a:3a:66 Driver rk_gmac-dwmac
inet addr:192.168.1.88 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::dd17:4f39:704f:3306/64 Scope: Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2386 errors:0 dropped:0 overruns:0 frame:0
TX packets:65 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:241522 TX bytes:6633
Interrupt:48
# Use eth0 to access the Internet
root@linaro-alip:/# ping -I eth0 -c 8 www.baidu.com
PING www.wshifen.com (103.235.46.96) from 192.168.1.14 eth0: 56(84) bytes of data.
64 bytes from 103.235.46.96 (103.235.46.96): icmp_seq=1 ttl=45 time=277 ms
64 bytes from 103.235.46.96 (103.235.46.96): icmp_seq=2 ttl=45 time=270 ms
64 bytes from 103.235.46.96 (103.235.46.96): icmp_seq=3 ttl=45 time=225 ms
64 bytes from 103.235.46.96 (103.235.46.96): icmp_seq=4 ttl=45 time=272 ms
64 bytes from 103.235.46.96 (103.235.46.96): icmp_seq=5 ttl=45 time=275 ms
64 bytes from 103.235.46.96 (103.235.46.96): icmp_seq=6 ttl=45 time=255 ms
64 bytes from 103.235.46.96 (103.235.46.96): icmp_seq=7 ttl=45 time=221 ms
64 bytes from 103.235.46.96 (103.235.46.96): icmp_seq=8 ttl=45 time=281 ms
--- www.wshifen.com ping statistics ---
8 packets transmitted, 8 received, 0% packet loss, time 7008ms
rtt min/avg/max/mdev = 220.731/259.456/280.557/22.381 ms
cat /etc/network/interfaces
auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1
sudo systemctl restart networking
# or
reboot
#include <stdio.h>
#include <stdio.h> <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <assert.h>
#include <sys/types.h>
#include <sys/socket.h>
int main()
{
int sockfd = socket(AF_INET, SOCK_DGRAM, 0);
assert(sockfd != -1);
struct sockaddr_in saddr, caddr;
memset(&saddr, 0, sizeof(saddr));
saddr.sin_family = AF_INET;
saddr.sin_port = htons(6000);
saddr.sin_addr.s_addr = inet_addr("127.0.0.1");
int res = bind(sockfd, (struct sockaddr *)&saddr, sizeof(saddr));
assert(res != -1);
while (1)
{
int len = sizeof(caddr);
char buff[128] = {0};
recvfrom(sockfd, buff, sizeof(buff) - 1, 0, (struct sockaddr *)&caddr, (socklen_t *)&len);
printf("buff=%s\n", buff);
if (strncmp(buff, "end", 3) == 0)
{
break;
}
sendto(sockfd, "ok", 2, 0, (struct sockaddr *)&caddr, sizeof(caddr));
}
close(sockfd);
exit(0);
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <assert.h>
#include <sys/types.h>
#include <sys/socket.h>
int main()
{
int sockfd = socket(AF_INET, SOCK_DGRAM, 0);
assert(sockfd != -1);
struct sockaddr_in saddr;
memset(&saddr, 0, sizeof(saddr));
saddr.sin_family = AF_INET;
saddr.sin_port = htons(6000);
saddr.sin_addr.s_addr = inet_addr("127.0.0.1");
while (1)
{
char buff[128] = {0};
printf("input\n");
fgets(buff, sizeof(buff), stdin);
if (strncmp(buff, "end", 3) == 0)
{
break;
}
sendto(sockfd, buff, strlen(buff), 0, (struct sockaddr *)&saddr, sizeof(saddr));
memset(buff, 0, sizeof(buff));
int len = sizeof(saddr);
recvfrom(sockfd, buff, sizeof(buff) - 1, 0, (struct sockaddr *)&saddr, (socklen_t *)&len);
printf("recv: %s\n", buff);
}
close(sockfd);
exit(0);
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <assert.h>
#include <sys/types.h>
#include <sys/socket.h>
int main() {
int sockfd = socket(AF_INET, SOCK_STREAM, 0);
assert(sockfd != -1);
struct sockaddr_in saddr;
memset(&saddr, 0, sizeof(saddr));
saddr.sin_family = AF_INET;
saddr.sin_port = htons(6000);
saddr.sin_addr.s_addr = inet_addr("127.0.0.1");
int res = bind(sockfd, (struct sockaddr *)&saddr, sizeof(saddr));
assert(res != -1);
res = listen(sockfd, 5);
assert(res != -1);
while (1) {
struct sockaddr_in caddr;
socklen_t len = sizeof(caddr);
int clientfd = accept(sockfd, (struct sockaddr *)&caddr, &len);
assert(clientfd != -1);
char buff[128] = {0};
recv(clientfd, buff, sizeof(buff) - 1, 0);
printf("Received: %s\n", buff);
if (strncmp(buff, "end", 3) == 0) { break;
}
send(clientfd, "Message received", 16, 0);
close(clientfd);
}
close(sockfd);
exit(0);
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <assert.h>
#include <sys/types.h>
#include <sys/socket.h>
int main() {
int sockfd = socket(AF_INET, SOCK_STREAM, 0);
assert(sockfd != -1);
struct sockaddr_in saddr;
memset(&saddr, 0, sizeof(saddr));
saddr.sin_family = AF_INET;
saddr.sin_port = htons(6000);
saddr.sin_addr.s_addr = inet_addr("127.0.0.1");
int res = connect(sockfd, (struct sockaddr *)&saddr, sizeof(saddr));
assert(res != -1);
while (1) {
char buff[128] = {0};
printf("input\n");
fgets(buff, sizeof(buff), stdin);
if (strncmp(buff, "end", 3) == 0) {
break;
}
send(sockfd, buff, strlen(buff), 0);
memset(buff, 0, sizeof(buff));
recv(sockfd, buff, sizeof(buff) - 1, 0);
printf("recv: %s\n", buff);
}
close(sockfd);
exit(0);
}