How to switch between networks from a Java application?

断了今生、忘了曾经 提交于 2019-12-13 07:15:35

问题


Is it possible to disconnect from one wi-fi network and connect to another network programatically using java?

My java application makes request to twitter using twitter4j. I can make only 350 requests per hour from a particular IP address. Now I'm sleeping for an hour before continuing my requests. But I have two Wi-Fi networks to connect to.

So when the limit exceeds and I get an exception, if I can switch between the networks, I can double the amount of work done. Is it possible in java?


回答1:


It's only possible in java because java can call native code. You would need to implement this with native code in C or C++.




回答2:


You could execute from your Java program an external program that would disconnect and reconnect (if you get an IP via DHCP).

Doesn't seem like the solution lies in the program, though. More in the way it's being used... or what it's being used (or shouldn't be used) for.



来源:https://stackoverflow.com/questions/11020965/how-to-switch-between-networks-from-a-java-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!