[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Connecting a device...

Posted on 2004-11-28
11
Medium Priority
?
233 Views
Last Modified: 2010-04-21
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
0
Comment
Question by:xenia27
  • 5
  • 5
11 Comments
 

Author Comment

by:xenia27
ID: 12693665
Is there any reference I can study?  About network and detecting device or anything I need to know??
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 12693819
> 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
 
LVL 16

Expert Comment

by:manav_mathur
ID: 12694472
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:xenia27
ID: 12694573
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
 
LVL 16

Accepted Solution

by:
manav_mathur earned 2000 total points
ID: 12694610
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
 
LVL 16

Expert Comment

by:manav_mathur
ID: 12694637
Have a look at this ->

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

might help you.

Cheers
Manav
0
 

Author Comment

by:xenia27
ID: 12703396
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
 
LVL 16

Expert Comment

by:manav_mathur
ID: 12704616
0
 

Author Comment

by:xenia27
ID: 12712411
Does this code work in Linux?
Any other example???
0
 
LVL 16

Expert Comment

by:manav_mathur
ID: 12713921
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
 

Author Comment

by:xenia27
ID: 12714055
OK...I'm working these codes now...thanks for helping~~~~
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

873 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