LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Control home appliance via internet (https://www.linuxquestions.org/questions/programming-9/control-home-appliance-via-internet-57775/)

juby 05-02-2003 01:58 AM

Control home appliance via internet
 
Hi
i am doing a project by which we can control a home appliance using a computer (light bulb, fan etc ). It has been implemented and it works fine on a given network .. but I want to extend its functionality across the internet.

The issue is
->
how do i get the ip add of the machine that is running my app ; if i have a dialup connexion. and the isp assigns a dynamic ip each time i connect..

i use Java as the Client & C on the target machine

any views , links will be welcome

yrraja 05-02-2003 04:51 AM

You can use ioctl() to get the IP address associated with your interfaces. I have used it with only ethernet cards but its behavior with modems should be the same. If you have Rechard Stevens "Unix Network Programming V1" then you can get the code for doing this form it.

Yaser

Mik 05-02-2003 04:56 AM

Sign up at one of those dynamic dns services. And have it updated automatically each time you connect to the internet. Usually the sites will tell you how to update it automatically in their documentation/faq.

yrraja 05-02-2003 05:11 AM

In that case too you would need to get your current IP address. Once Mik helped me out by sending me the code for doing this. Check out the following thread:

http://www.linuxquestions.org/questi...threadid=34871

Yaser

Mik 05-02-2003 05:47 AM

Well you wouldn't need any code to lookup the current ip address. Maybe I should explain more clearly what I meant.

You sign up at one of those dynamic dns services. You then don't need an ip adres but have a fixed domain name. The java client can use the fixed domain name. Now all you need to do is to get the server to update the ip number everytime you reconnect to the internet. Depending on what dynamic dns service you use they usually have small programs which connect to their servers to update the ip address. Or it's just a few lines which you can add to your connection script.

juby 05-02-2003 10:16 AM

hi.. i think the topic isnt very clear.. i want to get the ipadd of the machine @ my home and control it from a machine in my college lab.. hope this makes it clear

juby 05-02-2003 11:01 PM

I visited a few dns sites .. the solution is quite appealing..thanx for ur help .. can anyone tell me hoe to the same thing in code..

this is what i thnk abt

ping all the machines on port no: 7388 ( a socket wil be waiting for incoming connections) for a given isp then send a user id & password string .. if the userId & pwd matches establish a socket based conxn to that machine & send ur control signals.. will that work ..can i ping all machines of a isp on that port ??

juby 05-02-2003 11:06 PM

when i meant ping @ 7388 i mean something like portscaning :)

yrraja 05-04-2003 11:33 PM

Have you considered Multicasting. Here is what i think can work:

SERVER:
1) Your server starts, gets its own current IP address (using the code i told u about earlier.
2) Opens a port for a already decided Multicast address and starts transmitting its IP and Port address after every 5 seconds.

CLIENT:
1) Opens a Multicast socket at the address and port already decided and starts waiting for Multicast message from your server.
2) When it receives the message it extracts the IP address and uses it to connect to the server.

You may use techniques to encrypt these multicast messages if you need secutrity. The this works on local LAN but i dont know about Internet. Theoratically there should not be any difference if all the routers in the path a Multicast enabled.

Maybe some guru can shed some light on this.

Yaser

Mik 05-05-2003 02:48 AM

Well the multicast idea isn't going to work. That would require you to send your packets all over the world. Beside the fact that you wouldn't want to go broadcasting your ip every 5 seconds, imagine what a mess the internet would be if everyone would start doing that.

I also wouldn't recommend doing a portscan. Your ISP might send you a very upsetting letter if you do that too often.

I would stick to the dynamic dns solution.

Looking_Lost 05-05-2003 02:56 AM

Here's my bright idea:

Write a small java program that sends an email to yourself or whatever email address and schedule it to run whenever you want. Access the email from whatever means and look at the header - it should have your IP address in it from the sender.

It might not be very practicle but it's a workaround without getting any third parties involved.

yrraja 05-05-2003 03:00 AM

Hi Mik,

you say that Multicating wont work, are you saying this only because of the traffic it would generate over the internet or there is some other limitation of multicast?

As far as the security issue that you have mentioned that could be easily be over come by using some publically available code for RSA encryptions (public private keys) or some other encryption.

Yaser

Mik 05-05-2003 03:02 AM

Well technically speaking that would be involving a mailserver which is another third party. And it would ofcourse require you to manually extract the ip address each time you want to connect unless you add some code to read the ip from the email in the client.

Hmm, I'm being very critical today.

Looking_Lost 05-05-2003 03:29 AM

I guess so if you want it all done automatic but if it's just a personal project that no-one else is going to use it's easy enough to do as I said. But if it's an app that's intended in the end up to be used by anyone there's always going to be this problem and...

.. then static IP or Dynamic DNS is a just about a must for server app as you said eons ago

Mik 05-05-2003 03:51 AM

Well it is possible to get multicast working through the internet. Not exactly the same as just multicast on a local lan though. And there have been techniques developed so it won't be broadcasted to the whole world. But personally I don't think it's the proper approach to take to solve your problem.


All times are GMT -5. The time now is 07:26 PM.