Solved

Ethernet Question

Posted on 2002-07-25
3
337 Views
Last Modified: 2010-04-22

Hi, I'm new to Linux programming.  I have two systems connected to each other via ethernet, and I'm attempting to get them to communicate with each other.

I have no idea where to begin, but I would like to end up with a situation where both systems will be listening for a transmission from the other, and then jump into action when they receive one.

I program in C/C++ and the ethernet chip is a NatSemi.  Could someone please point me in the right direction?  I am preparred to do a lot of reading for this.

Thanks!!
0
Comment
Question by:iamundson
3 Comments
 
LVL 5

Expert Comment

by:bryanh
ID: 7181098
If you're looking for the basics - how to edit a file and compile a program on Linux, I don't have any references for you, but your local bookstore, Amazon.com, or O'Reilly Associates (ora.com) seem like the best places to go.

Similarly, getting the Ethernet interfaces up to where you can use 'ping' to talk from each to the other is pretty basic (and usually is pretty much done for you by your operating system builder).

But when you get to the specifics of writing programs to listen for messages from each other, I recommend you look a the Netcat program (look it up on freshmeat.net).  Netcat establishes a communication channel over an IP network (which is undoubtedly what you want to run on your Ethernet).  With Netcat, you can write your program just to read and write Standard Input and Standard Output (read(), write(), etc.), using a command shell to hook your program up to Netcat and thus to the network.  Plus, you can play with Netcat from the command line until you're comfortable.

And if that isn't exactly what you need, the Netcat source code is a great lesson on how to do the communication directly.
0
 
LVL 5

Accepted Solution

by:
garboua earned 100 total points
ID: 7184041
well first of all, connecting your two boxes.
you can use gui linuxconf and setup host names IP addresses and masks.
or you can use command line with "ifconfig" for more information on specifics "man ifconfig"

now after your two boxes can see each other, you need a simple network programming guide.  There is a very good and comprehensive explanation and example on the web.  Go to
http://www.ecst.csuchico.edu/~beej/guide/net/ and download the best format of document and start reading.
PAY Close attention to the select function, because it is WHAT YOU WANT.  You select a port, create a socket, bind it and then YOU give it to the operating system and tell it to tune to this file descriptor until either a read or write request occurs.
This can be done with C/C++ among other lanuguages.

also check www.priatehaven.org/beej

good luck


Ps.  If you are running a redhat system, type "setup", you must be root", and then select network configuration and fill your information.  to give your pc a name, alias, type "hostname NameofYourChoice"
function gethostname gethostbyname getenv are very usefull among others.  type "man gethostname" Or "info gethostname" and you could be on your way.
good luck again
0
 

Author Comment

by:iamundson
ID: 7201570

Thanks!!  Just what I was looking for.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now