Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > C program to communicate over ethernet

Reply
Thread Tools

C program to communicate over ethernet

 
 
polkid@gmail.com
Guest
Posts: n/a
 
      07-28-2006
I need some guidance here please!

I need to write code to talk from a PC to a DAQ type of thing, and have
there be a stream of data back and forth between them. I don't want to
use TCP because I dont need all those headers and whatnot, that's just
extra information. This is just between 2 machines, no routing needed.

So where do I look? How do I start? Everything I find talks about IP
addresses and stuff. I just need to stream bytes over ethernet.

(A side note, is sockets() just a TCP thing?)

Thanks!

Wade Polk

 
Reply With Quote
 
 
 
 
EventHelix.com
Guest
Posts: n/a
 
      07-29-2006
> I need some guidance here please!
>
> I need to write code to talk from a PC to a DAQ type of thing, and have
> there be a stream of data back and forth between them. I don't want to
> use TCP because I dont need all those headers and whatnot, that's just
> extra information. This is just between 2 machines, no routing needed.
>
> So where do I look? How do I start? Everything I find talks about IP
> addresses and stuff. I just need to stream bytes over ethernet.
>
> (A side note, is sockets() just a TCP thing?)


I would strongly recommend using UDP or TCP to transport the data. In
all other cases you will end up with a lot of code that may not be
readily portable to other platforms.

Use socket APIs to write your program and it will be easily portable to
any platform.

--
VisualEther 1.0 - http://www.EventHelix.com/VisualEther
Visual protocol analysis and sequence diagram generation from Ethereal


 
Reply With Quote
 
 
 
 
SM Ryan
Guest
Posts: n/a
 
      07-29-2006
"EventHelix.com" <(E-Mail Removed)> wrote:
# > I need some guidance here please!
# >
# > I need to write code to talk from a PC to a DAQ type of thing, and have
# > there be a stream of data back and forth between them. I don't want to
# > use TCP because I dont need all those headers and whatnot, that's just
# > extra information. This is just between 2 machines, no routing needed.
# >
# > So where do I look? How do I start? Everything I find talks about IP
# > addresses and stuff. I just need to stream bytes over ethernet.
# >
# > (A side note, is sockets() just a TCP thing?)
#
# I would strongly recommend using UDP or TCP to transport the data. In
# all other cases you will end up with a lot of code that may not be
# readily portable to other platforms.
#
# Use socket APIs to write your program and it will be easily portable to
# any platform.

Even over 'simple' connections, there is so much overhead dealing
with unusual conditions, synchronisation, bufferring, etc that you
get for free if you use TCP. Unless you really know what you're
doing or dealing with real strange system, you are far better off
learning the existing library instead of writing your own.

Besides the TCP interfaces your system might provide, there are
other libraries like the Tcl C API which are even easier to use
and more portable.

--
SM Ryan http://www.rawbw.com/~wyrmwif/
A bunch of savages in this town.
 
Reply With Quote
 
polkid@gmail.com
Guest
Posts: n/a
 
      07-31-2006
Thanks! I guess I just didnt want to use TCP because the program
doesn't need to be portable. It's going to be written to work between
two computers and no others ever. But I'll take your advice and write
it using TCP and see how it goes.

 
Reply With Quote
 
Tom St Denis
Guest
Posts: n/a
 
      07-31-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> I need to write code to talk from a PC to a DAQ type of thing, and have
> there be a stream of data back and forth between them. I don't want to
> use TCP because I dont need all those headers and whatnot, that's just
> extra information. This is just between 2 machines, no routing needed.


UDP?

Failing that you can also try IPX. It has no routing.

> So where do I look? How do I start? Everything I find talks about IP
> addresses and stuff. I just need to stream bytes over ethernet.


Um, you could send broadcast UDP packets and listen on 0.0.0.0

> (A side note, is sockets() just a TCP thing?)


No. In Linux/BSD you can use the sockets API to deal with raw IP, raw
802.3, raw whatever. YMMV as the lesser portable methods are less
documented.

Tom

 
Reply With Quote
 
Walter Roberson
Guest
Posts: n/a
 
      07-31-2006
In article <(E-Mail Removed) .com>,
EventHelix.com <(E-Mail Removed)> wrote:

>I would strongly recommend using UDP or TCP to transport the data. In
>all other cases you will end up with a lot of code that may not be
>readily portable to other platforms.


True.


>Use socket APIs to write your program and it will be easily portable to
>any platform.


False though.

Readily portable to "other platforms" != "portable to any platform".
Sockets are not universal, and are not POSIX compliant on at least
one major popular operating system.

Using sockets is a lot better than rolling your own, which is unlikely
to get you to very many platforms. But no matter which API you use,
there will be some platform that it won't work on, even if said platform
has some kind of ethernet communications.
--
There are some ideas so wrong that only a very intelligent person
could believe in them. -- George Orwell
 
Reply With Quote
 
Joe Wright
Guest
Posts: n/a
 
      07-31-2006
(E-Mail Removed) wrote:
> Thanks! I guess I just didnt want to use TCP because the program
> doesn't need to be portable. It's going to be written to work between
> two computers and no others ever. But I'll take your advice and write
> it using TCP and see how it goes.
>


If you continue networking, learning TCP will prove useful. Doing it
some other way might be interesting but not likely useful in the future.

--
Joe Wright
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
 
Reply With Quote
 
robertwessel2@yahoo.com
Guest
Posts: n/a
 
      08-01-2006

Tom St Denis wrote:
> Failing that you can also try IPX. It has no routing.



While seriously OT...

Since when? IPX has been routable since it was derived from XNS 20+
years ago. Admittedly routing was not a standard feature of 1.x
versions of NetWare, but was certainly part of 2.0a (circa 1986), and
IPX routing has been available in numerous non-Novell products.

 
Reply With Quote
 
Tom St Denis
Guest
Posts: n/a
 
      08-01-2006

(E-Mail Removed) wrote:
> Tom St Denis wrote:
> > Failing that you can also try IPX. It has no routing.

>
>
> While seriously OT...
>
> Since when? IPX has been routable since it was derived from XNS 20+
> years ago. Admittedly routing was not a standard feature of 1.x
> versions of NetWare, but was certainly part of 2.0a (circa 1986), and
> IPX routing has been available in numerous non-Novell products.


IPX basically just used the MAC addresses IIRC. It was like UDP where
you had a port which identified the service.

MAC addresses are not routable because they are not hiearchical. Sure
you can manually map MAC addresses to given ports on a switch (for
instance, switches do this automatically as it discovers source
addresses) but it isn't scalable.

If there was any routing in IPX it was totally manual and host based
instead of network based like IP.

Tom

 
Reply With Quote
 
robertwessel2@yahoo.com
Guest
Posts: n/a
 
      08-01-2006

Tom St Denis wrote:
> (E-Mail Removed) wrote:
> > Tom St Denis wrote:
> > > Failing that you can also try IPX. It has no routing.

> >
> >
> > While seriously OT...
> >
> > Since when? IPX has been routable since it was derived from XNS 20+
> > years ago. Admittedly routing was not a standard feature of 1.x
> > versions of NetWare, but was certainly part of 2.0a (circa 1986), and
> > IPX routing has been available in numerous non-Novell products.

>
> IPX basically just used the MAC addresses IIRC. It was like UDP where
> you had a port which identified the service.
>
> MAC addresses are not routable because they are not hiearchical. Sure
> you can manually map MAC addresses to given ports on a switch (for
> instance, switches do this automatically as it discovers source
> addresses) but it isn't scalable.
>
> If there was any routing in IPX it was totally manual and host based
> instead of network based like IP.



No, IPX used a two part address, a 32 bit network number and a 48-bit
host number (plus a 16 bit port). On LANs with Ethernet-style MACs,
the host number was just assigned to the MAC, although in some (rare)
circumstances a manual assignment was used. In short, this was roughly
equivalent to an 80 bit "IP" address with a fixed "/32" subnet mask.

Non-routing machines normally required no address configuration (beyond
what the LAN hardware required - for example Arcnet would require that
you set the 8-bit "MAC" address on each card, either in hardware or
software). Non-routing hosts would learn their network number from a
router on that LAN (a particular broadcast query). Routers, of course,
*did* have to be configured with the correct network number on each
NIC.

Novell eventually set up a registry of network number assignments,
which assigned globally unique network number ranges (IOW,
"subnets" of the network number).

FWIW, a minor variation of RIP was the routing protocol of choice for
early XNS and IPX implementations, although Novell eventually migrated
to an OSPF-like link-state protocol (NLSP) somewhere in the NetWare 3.x
days.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
VOIP over VPN over TCP over WAP over 3G Theo Markettos UK VOIP 2 02-14-2008 03:27 PM
trying to use popen2() to communicate with C program I. Myself Python 4 03-28-2006 08:07 PM
Cisco SOHO 91 Router showing Ethernet 0 instead of Fast Ethernet 0 andyr Cisco 4 04-14-2005 01:12 PM
AAUI to Ethernet vs. AUI to Ethernet tranceiver? JXM2119 Cisco 2 03-11-2005 11:13 PM
Can 803 (ISDN-ethernet) work ethernet-ethernet? Peter Cisco 2 12-11-2003 11:24 PM



Advertisments