Solved

Ethernet Question

Posted on 2002-07-25
3
336 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
Comment Utility
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
Comment Utility
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
Comment Utility

Thanks!!  Just what I was looking for.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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 demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

772 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

11 Experts available now in Live!

Get 1:1 Help Now