Connecting a device...

Hi,

I try to write a program which will connect to a device through an IP address...and get the page data from the device and write it into a file.  How can I connect a device through a given IP address??  Any suggestion?  By the way, I'm using C to write the program in Red Hat 9...



Xenia
xenia27Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

xenia27Author Commented:
Is there any reference I can study?  About network and detecting device or anything I need to know??
0
ahoffmannCommented:
> How can I connect a device through a given IP address??
you first need a server/daemon/program running on the remote host listening on that IP. This program then can access the device and return what you want.
0
manav_mathurCommented:
xenia27,
Can you tell us what exacly this device is?? Is it local....in that case what you are asking is to 'bind' the device interface to a particular IP address. In case the device is remote, ahoffman is correct.

Manav
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

xenia27Author Commented:
This device is attached with computer...I mean connected through a network wire...not sure whether I use the correct word for it or not...anyway, I need to get some information from a machine through the network...I suppose it's a local...what's the different between connecting a remove machine and a local machine?  How will the program be different???
0
manav_mathurCommented:
xenia27,
You mean to say the device is *networked* to your PC.

in that case, as ahoffman has correctly pointed out, the device controller must already have assigned a IP address to it.
The only thing needed now is that the device must be *listening* out for any connection. i.e. there must be a prgram running on that device which is contantly on the lookout for any incoming connections.

If that is the case, you need to write a client program(in C). In that,
1) you need to create a socket
2) you need to connect to that IP(and possibly a particular port. On the same IP, different ports listen for different types of incoming connection. for eg, on a typical server port number 80 is looking for incoming http connections whereas port 23 is looking out for incoming telnet connections). you have to do this using that socket.
3) you can then read the socket to get your data.

I assume you are using TCP/IP for communications.

Manav



0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
manav_mathurCommented:
Have a look at this ->

http://www.paulgriffiths.net/program/c/echoclntsrc.html

might help you.

Cheers
Manav
0
xenia27Author Commented:
OK...I know this might not be in my question now...but I wonder how can I read data via RS232???  Is there any reference I can study?

Thanks for the information you provide...that's excellent~~  Thanks~
0
manav_mathurCommented:
0
xenia27Author Commented:
Does this code work in Linux?
Any other example???
0
manav_mathurCommented:
It must. I havent tried coz I dont have a LINUX machine at my disposal here.

But LINUX supports berkeley sockets. Why dont you try it out??

Manav
0
xenia27Author Commented:
OK...I'm working these codes now...thanks for helping~~~~
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux OS Dev

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.