Ethernet communications

Sorry for posting so many time I have a bunch of different
questions...anyways...I have ethernet setup so I can ping back and
forth from angstrom 2.6.28 to my computer, so the question is does
anyone have any examples of how to write c program to talk between the
two computers. I would like to send some data around. Just a hello
world in c would be great. Like type in hello world on beagle and have
it send it over ethernet to program on windows computer anyways. let
me know if anyone knows how to do that.

UDP or TCP? Here is a simple UDP example in C at:
http://www.abc.se/~m6695/udp.html

Both machines must be Unix/Linux

There are many, many other examples using TCP as well. Any linux example C code will work on Angstrom if you install the appropriate headers.

That Does not work with the native g++ compiler that I have in
angstrom 2.6.28.

Errors from server
UdpServer.c: In function 'void diep(char*)':
UdpServer.c:15: error: 'exit' was not declared in this scope
UdpServer.c: In function 'int main()':
UdpServer.c:25: warning: deprecated conversion from string constant to
'char*'
UdpServer.c:27: error: 'memset' was not declared in this scope
UdpServer.c:31: error: cannot convert 'sockaddr_in*' to 'const
sockaddr*' for ar
gument '2' to 'int bind(int, const sockaddr*, socklen_t)'
UdpServer.c:32: warning: deprecated conversion from string constant to
'char*'
UdpServer.c:35: error: cannot convert 'sockaddr_in*' to 'sockaddr*'
for argument
'5' to 'ssize_t recvfrom(int, void*, size_t, int, sockaddr*,
socklen_t*)'
UdpServer.c:36: warning: deprecated conversion from string constant to
'char*'
root@beagleboard:/home/cpp# vi UdpServer.c

Errors from Client
UdpClient.c: In function 'int main()':
UdpClient.c:6: error: aggregate 'sockaddr_in si_other' has incomplete
type and c
annot be defined
UdpClient.c:8: error: 'BUFLEN' was not declared in this scope
UdpClient.c:10: error: 'AF_INET' was not declared in this scope
UdpClient.c:10: error: 'SOCK_DGRAM' was not declared in this scope
UdpClient.c:10: error: 'IPPROTO_UDP' was not declared in this scope
UdpClient.c:10: error: 'socket' was not declared in this scope
UdpClient.c:11: error: 'diep' was not declared in this scope
UdpClient.c:12: error: 'memset' was not declared in this scope
UdpClient.c:13: error: 'AF_INET' was not declared in this scope
UdpClient.c:14: error: 'PORT' was not declared in this scope
UdpClient.c:14: error: 'htons' was not declared in this scope
UdpClient.c:15: error: 'inet_aton' was not declared in this scope
UdpClient.c:16: error: 'stderr' was not declared in this scope
UdpClient.c:16: error: 'fprintf' was not declared in this scope
UdpClient.c:17: error: 'exit' was not declared in this scope
UdpClient.c:20: error: 'NPACK' was not declared in this scope
UdpClient.c:21: error: 'printf' was not declared in this scope
UdpClient.c:22: error: 'buf' was not declared in this scope
UdpClient.c:22: error: 'sprintf' was not declared in this scope
UdpClient.c:23: error: 'sendto' was not declared in this scope
UdpClient.c:24: error: 'diep' was not declared in this scope
UdpClient.c:27: error: 'close' was not declared in this scope

Not sure how to fix these things besides get some sort of package my
compiler is missing, but I am not to sure how to do that.

That Does not work with the native g++ compiler that I have in
angstrom 2.6.28.

It seems these are C files, don't use the C++ compiler.

Laurent

How Can I put a c compiler onto the beagle board? is there something
similar to getting the native c++ compiler on here, but for a c
compiler?

I you already have g++ on your Beagle, I guess you also have gcc.

Laurent

Or does someone have some c++ examples for TCP communications. The
code above is very similar to what I am looking for, I just need
something that I can get working.

Thanks again!

Am I doing something wrong here, I have tried typing it a few
different ways but it is not compiling. Does this mean I do not have
the c compilers?

root@beagleboard:/home/cpp# ls
HawkNetHome UdpServer.c led.c ledgpp.c simplelq.c
UdpClient.c helloworld ledcblink simplelq strobe_gpio
root@beagleboard:/home/cpp# gcc -o UdpServer UdpServer.c
gcc: error trying to exec 'cc1': execvp: No such file or directory

Does this mean I do not have the c compiler? because that syntax works
the the g++.

Thanks for the help.

So it seems the proper syntax requires a capital .C not a .c. and
slightly different order

gcc UdpClient.C -o UdpClient

unfortunately same error...

UdpClient.C: In function 'int main()':
UdpClient.C:6: error: aggregate 'sockaddr_in si_other' has incomplete
type and c
annot be defined
UdpClient.C:8: error: 'BUFLEN' was not declared in this scope
UdpClient.C:10: error: 'AF_INET' was not declared in this scope
UdpClient.C:10: error: 'SOCK_DGRAM' was not declared in this scope
UdpClient.C:10: error: 'IPPROTO_UDP' was not declared in this scope
UdpClient.C:10: error: 'socket' was not declared in this scope
UdpClient.C:11: error: 'diep' was not declared in this scope
UdpClient.C:12: error: 'memset' was not declared in this scope
UdpClient.C:13: error: 'AF_INET' was not declared in this scope
UdpClient.C:14: error: 'PORT' was not declared in this scope
UdpClient.C:14: error: 'htons' was not declared in this scope
UdpClient.C:15: error: 'inet_aton' was not declared in this scope
UdpClient.C:16: error: 'stderr' was not declared in this scope
UdpClient.C:16: error: 'fprintf' was not declared in this scope
UdpClient.C:17: error: 'exit' was not declared in this scope
UdpClient.C:20: error: 'NPACK' was not declared in this scope
UdpClient.C:21: error: 'printf' was not declared in this scope
UdpClient.C:22: error: 'buf' was not declared in this scope
UdpClient.C:22: error: 'sprintf' was not declared in this scope
UdpClient.C:23: error: 'sendto' was not declared in this scope
UdpClient.C:24: error: 'diep' was not declared in this scope
UdpClient.C:27: error: 'close' was not declared in this scope

must be missing a library of some sort. This makes me wonder if the g+
+ compiler is any different than the gcc compilers. Anybody know how
to figure out which socket library exists in angstrom 2.6.28 gcc?

So it seems the proper syntax requires a capital .C not a .c. and
slightly different order

gcc UdpClient.C -o UdpClient

unfortunately same error...

All files named .C or .cpp will be compiled by the C++ compiler
even if you use gcc.

Laurent

I looked at the recommended simple UDP code, and the author of that
code did not repeat the necessary include statements and defines from
the server code in the client section. These are also needed in the
client code:
#include <arpa/inet.h>
#include <netinet/in.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>

#define BUFLEN 512
#define NPACK 10
#define PORT 9930

void diep(char *s)
  {
    perror(s);
    exit(1);
}

-Preston

Well that did fix some of the errors still have error when compiling
both of them though

client
UdpClient.C: In function 'void diep(char*)':
UdpClient.C:17: error: 'exit' was not declared in this scope
UdpClient.C: In function 'int main()':
UdpClient.C:26: warning: deprecated conversion from string constant to
'char*'
UdpClient.C:27: error: 'memset' was not declared in this scope
UdpClient.C:32: error: 'exit' was not declared in this scope
UdpClient.C:38: error: cannot convert 'sockaddr_in*' to 'const
sockaddr*' for ar
gument '5' to 'ssize_t sendto(int, const void*, size_t, int, const
sockaddr*, so
cklen_t)'

Server

UdpServer.C: In function 'void diep(char*)':
UdpServer.C:15: error: 'exit' was not declared in this scope
UdpServer.C: In function 'int main()':
UdpServer.C:25: warning: deprecated conversion from string constant to
'char*'
UdpServer.C:27: error: 'memset' was not declared in this scope
UdpServer.C:31: error: cannot convert 'sockaddr_in*' to 'const
sockaddr*' for ar
gument '2' to 'int bind(int, const sockaddr*, socklen_t)'
UdpServer.C:32: warning: deprecated conversion from string constant to
'char*'
UdpServer.C:35: error: cannot convert 'sockaddr_in*' to 'sockaddr*'
for argument
'5' to 'ssize_t recvfrom(int, void*, size_t, int, sockaddr*,
socklen_t*)'
UdpServer.C:36: warning: deprecated conversion from string constant to
'char*'

Thanks for the help...I aam not sure how to fix all of these. I think
I am missing some library or something.

I will make a new post asking how to get a c compiler setup in
angstrom 2.6.28..

Those are *.c files not *.C, please rename them as *.c and fix your gcc to compile them as c code.

I have tried to compile the files with gcc using the .c extension, but
then I get the error...

gcc: error trying to exec 'cc1': execvp: No such file or directory
root@beagleboard:/home/cpp#

If I use the .C extension the program will compile. but it seems that
it uses the c++ compiler.

and fix your gcc to compile them as c code.

I am not sure what you mean by the above statement?