I have some socket code that works on my Linux box but FAILS on my PowerPC box.
The code (when working on the Linux box) receives a data from a client and then sends the data back to the client. When tested with two netcat applications - the data is successfully wrapped around.
PROBLEM: When tested on a PowerPC (running VxWorks), the echoed data is never received by the client ... (netcat and wireshark show nothing).
On the PowerPC, the server successfully RECEIVES the data (from an x86 client) and claims it successfully ECHOED it back ... but NO DATA is received on the client (netcat on an x86) ... me thinks I may have committed some ENDIAN foobar somewhere. Here is the code snippet as exists on the PowerPC. With two x86 Linux boxes the code works fine ...
while(1)
{
readlen = recvfrom(sock, buf, BUFLEN, 0, (struct sockaddr *) &client_address, &slen);
if (readlen == ERROR)
{
printf("RECVFROM FAILED()/n");
return (ERROR);
}
printf("Received %d bytes FROM %s:%d\nData: %s\n\n",
readlen, inet_ntoa(client_address.sin_addr), ntohs(client_address.sin_port), buf);
// Send it to right back to the client using the open UDP socket
// but send it to OUTPORT
client_address.sin_port = htons(OUTPORT);
sendlen = sendto(sock, buf, BUFLEN, 0, (struct sockaddr *)&client_address, slen);
// more code ....
}
Maybe I need to htons the client address too? ...