Creating a server socket in beaglebone - c

I'm new in using beaglebone, and I need some help about some issues I'm facing.
I wrote a code in c (running in a laptop with ubuntu) in which a server socket is opened (running an apache server), and then another device connects to it through internet.
I would like to do the same in the beaglebone with ansgtrom distro (the one that comes with the board). I have read that angstrom distro comes with cloud9 (which from what I understand it acts as a server, like apache).
So, how can I create/open/use a server socket (through a program written in c) in cloud9-beaglebone?
Also, how can I configure cloud9 to store certain webpage? Is such configuration similar to the one in apache?

Cloud9 IDE is an IDE for developing code for Node.JS.
The version of Node.JS used today is 0.6.20. There are examples on the nodejs.org home page and for the particular version at http://nodejs.org/docs/v0.6.20/.
To serve up web pages, I recommend you look into frameworks like ExpressJS. You can use the 'npm' utility under the Cloud9 IDE or the command line to install ExpressJS.
Since Cloud9 IDE allows you to edit C code, you can create typical C code that opens and serves sockets. pkg-config is installed to help you with linking libraries. You'll want to go to https://beaglebone.local to use Gate One to ssh into the board (username: root, password: ) and run the C compiler from the command line. You can use the same tools you'd use under Ubuntu, like 'make' and 'g++'.

Related

"dronekit-sitl waiting for connection..." But what am I to do next?

I have installed it. But what to do next?
MavProxy application doesn't respond to commands or am I doing something wrong over here.
In short, someone please guide me through connecting simulated vehicle with mission planner. I know it is very rudimentary but please help me out here.
To connect dronekit-sitl to Mission Planner simply just set the connection setting (at the top right) to TCP then click the connect button and set the remote IP 127.0.0.1 and remote port to 5760. Like in this picture:
And you should be connected to the dronekit-sitl, the developer actually specify the connection setup at their docs Link.
But I recommend you to not use the dronekit-sitl if you are using it to develop program using dronekit. Just use the original SITL from Ardupilot site Link. Why ? because the dronekit-sitl is limited to the version 3.3 firmware (Right now the latest firmware is 3.6) and you can't do advanced testing with it (Like simulate LIDAR, Wind simulation, even connecting your SITL to 3D Simulator).
A tips from me is if you want to develop your program in Windows and use the Mission Planner as GCS you can enable the Windows Subsystem for Linux (WSL) Link and install Ubuntu to the WSL and follow the SITL setup on Linux guide Link.
OR just use Ubuntu to develop your program and use APM Planner as your GCS Link or just install Mission Planner on Ubuntu using WINE/Crossover (This is the option I use right now).

Running C on webpage

I have a client server program on C. The program has used libraries such as ffmpeg, libfftw3 etc, now I want to run it on my webpage. I have object files as well as executable files compiled from the C programs. I was searching for some platform which will allow me to run the client-server, just like the way a shell script on terminal allows.
Can anyone please tell me how can I do it.
You can run the program "from your web page" if you rebuild your program using Google's Native Client (NaCl) libraries. https://code.google.com/p/nativeclient/
This builds an executable that is run from Chrome, on the users machine, inside a sandboxed environment. The executable is built and distributed in an intermediate, machine independent format that Chrome coverts into a runtime format when it downloads and runs the app.
The performance is good (a little slower than full speed). The downside is that you are limited to the NaCl libraries. And, you have to run the app with Chrome.
If you want to run this in a client-server configuration, you can have the server run on the same machine or on a different machine.
It's easier to write the server program on your own server machine once and communicate via sockets, otherwise you have to port it to all the machines you want it to run on.
If you are interested in running the server on your local machine, you can use WebSockets to connect simple web pages with HTML and JavaScript to the server.
The right approach depends on what your needs are.

TCP/IP Programming in C

I have an exam on tomorrow on TCP/IP programming. Following is one of the previous question on this paper.
Write and run a client and a server program. Using C language in UNIX, with the
following specifications :
• A TCP client program will send a range of number (e.g. 1 to 10) to the server.
• TCP server accept the number range from client and send back the sum of the
number range. Client will print the result.
I dont know how to setup the compiler and other settings to run this tcp ip programs. When I search online, I got two different programs, one for Client and another For server. Some please tell me how can i run these programs to get desired output. What kind of compiler should I install on my system.( I am using windows 7) ??
Since the assignment requires your code to work on a Unix system, you first need to install one. Follow these simple steps to install a virtual Unix environment on top of your existing Windows installation.
Download and install VirtualBox for Windows.
Download & unpack this Ubuntu 12.10 disc image (NOTE: Requires 7-Zip).
Launch VirtualBox and create a new Virtual Machine (name it Ubuntu).
In the "Virtual Hard Disk" settings, select "Use existing hard disk" and select the image file you just downloaded (NOTE: It's filename should end in ".vdi").
Run your new Virtual Machine. You should see the Ubuntu splash screen.
Login with username ubuntu and password reverse (NOTE: Case Sensitive!).
Open up Terminal and type sudo apt-get install build-essential (NOTE: when Terminal prompts you for a password, use reverse).
You should (with hope) have everything you need for your assignment. For more information on network programming, consult Beej's Guide to Network Programming -- Using Internet Sockets.
You need to open two different terminals on your system.
In the first terminal compile and run the server.c program.(make sure either you listen to all ips or your host ip(atleast).
while this is running.(it will wait for a request from your client program)
Run the client program in the other terminal.
Hope this solves the problem!
For details on how to create and run a file in unix refer http://www.wikihow.com/Compile-a-C-Program-Using-the-GNU-Compiler-%28GCC%29
P.S: you can do the same in win7 if iam not wrong only that terminal here in called command prompt!
Post the results if possible!
Download a thing called VMWare player. And look for a Ubuntu image that you can load with the VMWare player. That way, you will have a little Linux virtual machine that you can run inside or along with Windows 7. You can use the compiler GCC in your Ubuntu or whatever other Linux virtual machine. And get lots of coffee. Blargle is correct, but I think my suggestion is a little better, because you end up having a fairly complete Unix type environment to develop in. Blargle's way put Unix tools on top of Windows, which I find to be kind of clunky.
I learnt socket programming from this site. He has given everything in detail . Download an Vmware workstation and load up ubuntu . Understand the programs they are pretty much straight forward .
Maybe you can try to look at Network Socket on the web. You can easily find a lot of good tutorial that can answer your question.
You can use the compiler you want on your system, depending on what are you using now.

using libcurl to create a standalone site-polling program

I am creating a standalone (no DLLs) windows C/C++ program that uses HTTP POST to periodically send data to an HTTP server. I identified libCURL as the HTTP client library as it seems simple and reliable.
I still need to identify the environment (an IDE) which I can use to develop my project. My program has:
poller- which checks the status of the connection
a file writer when polled link is down
a component which POSTs the file when link is up
What is the appropriate IDE for this project? I heard endorsements for DevC++ and Visual C.
I am a newb to coding and this site. Pardon me if I am unclear in anything.
Any IDE will fit your need. Just install one of them and start coding.
Try CodeBlocks. It is light, more easy to work with and has more features than Dev C++.

Eclipse cross-compile... how can I do that?

I am developing on a Windows machine using Eclipse in C code.
All the files are physically located on a Linux server.
I am using Eclipse only for editing and code browsing.
When I want to compile, I open a terminal and telnet to the Linux server from which I call a file that sets up few variables and eventually invoke a "make" command.
The server is pretty busy.. I would then like to be able to compile locally [and then just ftp these executable files back to the Linux machine so that I can execute them.. unless Eclipse can do that on its own :) ].... any idea how can that be done? I am not well versed in Eclipse or OS usage.... so if you could answer and explain what I should do.. I would really appreciate...
I changed the Build Command under Project Properties menu by just calling the script file on the server I usually invoke to compile... That looked fairly simple.. well... that was too good to be true... and of course.. it didn't work! I am getting this error if I use the default "make" (Cannot run program "make": Launching failed).... while getting (Cannot run program "T:\compile": Launching failed) if I try to invoke my script file that I use to compile...
thanks,
You should take a look at running a crosstool-ng setup on your windows box inside cygwin. And then have eclipse use that compiler. This will allow you to develop for your target Linux platform easily.
Here's some slides
It sounds like you're developing for a desktop/server platform, so you'll have to make sure you set up your crosstool-ng with the same versions of standard libs as your server has (libc, libstdc++, etc). You also want to make sure your crosstool-ng has the same version of gcc as the target as well.
If you don't want to mess with getting all that setup, you could always install Linux as a virtual machine on your windows box and work inside there.

Resources