I have a simple UDP server program
#include <sys/socket.h>
#include <netinet/in.h>
#include <stdio.h>
#include <string.h>
int main(int argc, char**argv)
{
int sockfd,n;
struct sockaddr_in servaddr,cliaddr;
socklen_t len;
char mesg[1000];
sockfd=socket(AF_INET,SOCK_DGRAM,0);
bzero(&servaddr,sizeof(servaddr));
servaddr.sin_family = AF_INET;
servaddr.sin_addr.s_addr=htonl(INADDR_ANY);
servaddr.sin_port=htons(54000);
bind(sockfd,(struct sockaddr *)&servaddr,sizeof(servaddr));
for (;;)
{
len = sizeof(cliaddr);
n = recvfrom(sockfd,mesg,1000,0,(struct sockaddr *)&cliaddr,&len);
sendto(sockfd,mesg,n,0,(struct sockaddr *)&cliaddr,sizeof(cliaddr));
printf("-------------------------------------------------------\n");
mesg[n] = 0;
printf("Received the following:\n");
printf("%s",mesg);
printf("-------------------------------------------------------\n");
}
}
~
I compile it
gcc -m32 -o udp_server udp_server.c
and run it(./udp_server
) on several linux machines, it works fine and I use a udp client client to send packets to the UDP server on these machines, they are accepted
but I have a new machine(let me call it A), it is relatively strange compared to other linux machines, as shown in https://superuser.com/questions/581442/ifconfig-command-not-found anyway it has no "eth0" and the interfaces are:
[root@kitch proxy]# ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: em1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT qlen 1000
link/ether 00:1a:a0:23:86:6c brd ff:ff:ff:ff:ff:ff
First, I run the 32-bit-version of the program on it and I got
-bash: ./udp_server: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory
Then, second, I compile the UDP program without '-m32' and run it on the machine A, it runs normally Then I use UDP client to send packets to the UDP server on A I can capture the sent packets on this machine, but the UDP server doesn't accept those packets,
are there any potential reasons for this? maybe the binding doesn't work here because this machine is special? thanks!