in this early morning about 6.27am, i got questioned about how the socket programming works.
And yet, I found tons of discussion here and there about it.
But, again, with a minimum of experience regarding about the networking stuff, here
I wanted to ask you guys... perhaps you already know rather than me.
I'm still seeking answer through google and other forum, tough.
okay, suppose, this PC is already connected through Internet.
And a user open up browser Internet Explorer for example.
And how could we implement a Java Application, running
and listening to the incoming response?
Should I use proxy or something?
But how java could have smthg like filtering here?
I came across from other respond,
and then My friend told me "Try to implement a single thread, and active thread using serverSocket...
Listening to some specific port."
but again, i have a limited shade of lightness here.
~ I need advice.
I just figured it out here.
Eventhough, my work still not completed yet.
If you ever noticed at the Windows Environment
there's an Internet Option, and also Proxy server there.
(I.E user also may noticed about this)
Why dont we bind our ServerSocket into it (proxy server)?
Instead of putting the outsider IP Address as Proxy Server,
why dont we use the localhost (our self) as proxy server, and of course
using a different port opened.
Thus, the response from INTERNET (outsiders) would eventually going through
our ServerSocket first, then showed to the browser...
i was thinking this way.... how could that be, Stephan van Hulst?
you will have to access it through your Java application itself. Is this still acceptable for your requirements?
nope. that's not what we want it.
to access outside (INTERNET) via browser, common browser.
Not the java app as browser.
after reading a bit
Now, what i need now is how to setup the proxy server in java
so when it runs, it will make itself as filtering apps
by obtaining the response from outside...
and again bind it to our localhost...
if there's anyone know about this already,
please post up some suggestion...
I also found out some suggestion from my friend telling me,
you need to use two socketServer 1 on 80 port and another one socketServer 2 as a proxy port (customizable; example 3000).
And then, he pointed to me that these need to be in a separated thread (running), thus each of them are communicating
as a well proper internet filter.
But that one makes me confused even more.
By having two socketServer at the same time? I said to him.
And he replied me.
Well, yes. Even in a single file it doesnt matter. What the main concern is that this pc used, is connected to internet.
And the Internet Option is using Proxy Server to be enabled... and it's bind to 127.0.0.1
Which means the proxy is himself (127.0.0.1:3000)
And then I asks my self whetherthis is possible?
That the Browser would eventually talk with the proxy first then to the outside (internet)...?
He eventually talking to me that...
But remember the inputstream and outputstream need to be coupled with those socketservet running without end.
Now I become more confused.
I found a lack understanding while
opening the muffin source code (zip)
does anyone have idea about this?
actually, would it be possible if let say
1 pc using socket open to the internet,
and another socket open to the local browser?
please review this image
Uploaded with ImageShack.us
I was thinking that the proxy server should be applied locally
but different than the port 80.
i tried to implement this algorithm but it's unsufficient for making a local proxy server
as a filtering app.
Please review if anyone may do it here;
1) Initiate serverSocket
2) iterate looping without end, do accepting input
3) create the socket receiving the input request
4) read in the buffer-in from socket received, get the destination address
5) pass the address obtained (http://something.com) to url object
6) make HttpURLConnection supplied by url object created previously
7) write the buffer out from the buffer-out
again, i said this one is insufficient.
Since it's just taking in and out the requested data of Http
and the result is, the page obtained may be seen on the browser
without any image retrieved, or no css retrieved.
thanks for everyone !
now I made it!
The concept i used is that made 1 serversocket opened.
And then create one more socket to communicate with the real server.
Thus the serversocket would received the real respond from real server
after the socket get inputstream previously...
Now, I'm sure I can do for solving out this thread.
But seems the problem occured is that the bytes transferred is never been closed.
please take a look
The previous source code I just posted was the 2nd version,
that I tried to make.
And great, this is the 1st version of the source code.
This one is quite... more suffer (if i'm not mistaken).
Since it can't handle the streaming properly.
But sometimes it do filtering, and blockout the content of the web visited.
Anyway, if there's a suggestion in terms of the algorithm...
you may post up here.