I am writing a little program to search all ip adresses in my network for an appropriate respons.
But the ip addresses that do not have any server or service running give an error and even worse, it takes very long until the program continues to the next ip.
The error is not my problem, since it is only displayed in the console, but i want to limit the time it can take to wait for a respons. The servers i want to find easily respond within 500ms. So i set the program to give it 1000ms for each ip.
and here is the console output. The first address 192.168.192.23 finds what it is looking for and the next (.24) does not find a respons.
192.168.192.32
192.168.192.
scanbutton - GButton >> GEvent.CLICKED @ 8503
scanning
scanning IP: 192.168.192.23
Reponse Content: [3:903:1023]
Reponse Content-Length Header: 12
scanning IP: 192.168.192.24
org.apache.http.conn.HttpHostConnectException: Connection to http://192.168.192.24 refused
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:158)
at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:149)
at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:121)
at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:573)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:425)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:754)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:732)
at http.requests.GetRequest.send(Unknown Source)
at WFDFinder.scan(WFDFinder.java:52)
at WFDFinder.button1_click1(WFDFinder.java:89)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at g4p_controls.GAbstractControl.fireEvent(Unknown Source)
at g4p_controls.GButton.mouseEvent(Unknown Source)
at g4p_controls.GWindowImpl.mouseEvent(Unknown Source)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at processing.core.PApplet$RegisteredMethods.handle(PApplet.java:1411)
at processing.core.PApplet.handleMethods(PApplet.java:1613)
at processing.core.PApplet.handleMouseEvent(PApplet.java:2677)
at processing.core.PApplet.dequeueEvents(PApplet.java:2599)
at processing.core.PApplet.handleDraw(PApplet.java:2440)
at processing.awt.PSurfaceAWT$12.callDraw(PSurfaceAWT.java:1557)
at processing.core.PSurfaceNone$AnimationThread.run(PSurfaceNone.java:313)
Caused by: java.net.ConnectException: Operation timed out (Connection timed out)
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:123)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:148)
... 27 more
scanning IP: 192.168.192.25
I had a look at the example, but if i understand right, I will have multiple threads running at the same time, all sending a get request to different ip addresses. won’t this give issues? either with the pc or the network?
I will offcourse try it. just have to figure out how to implement it. but i think i can do it.
@Dennis I have found a sollution, but it means i have to make adjustments to the .net library.
However, when i make the changes and try to test my app, the changes do not make a difference. Do i need to recompile the library before i can use it? I tried restarting processing after the changes but still no difference.
I’m having trouble to rebuild the library so before i put more efford into it, i’d like to know if i have to rebuild it at all.