This commit is contained in:
Wolfgang Hottgenroth 2021-02-08 15:41:06 +01:00
parent d31743aab0
commit caef0253c7

View File

@ -1,5 +1,26 @@
#include <stdio.h> #include <stdio.h>
#include <sys/socket.h>
#include <string.h>
int main() { int main() {
printf("Hello world!\n"); int sockfd;
struct sockaddr_in servaddr;
sockfd = socket(AF_INET, SOCK_DGRAM, 0);
memset(&servaddr, 0, sizeof(servaddr));
servaddr.sin_family = AF_INET;
servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
servaddr.sin_port = htons(20169);
bind(sockfd, (SA*) &servaddr, sizeof(servaddr));
uint8_t buf[1024];
while (1) {
int n = recv(sockfd, buf, sizeof(buf), 0);
printf("received %d octets\n");
}
} }