• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

PC Connected to Internet and Internet Connectivity?

 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Greetings everyone!
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.
 
Saloon Keeper
Posts: 15490
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is it that you want to achieve specifically?
 
J. Insi
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
to obtain the incoming HTTP Response...
at the time user browsing the internet using the internet browser


... anyone may suggest me a couple thing exact to it?
 
Stephan van Hulst
Saloon Keeper
Posts: 15490
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't think you can intercept the response when you're using another program as the browser.

I think that if you want the response from the website, you will have to access it through your Java application itself. Is this still acceptable for your requirements?
 
J. Insi
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
okay that's the deal, Stephan van Hulst.

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.
 
J. Insi
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
and yes, i'm sure.
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...
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, you have a pointer to Muffin, right there, which is an excellent proxy server written in Java. It can be customized by writing your own filters in Java, so you can use it to do whatever it is you want to do.
 
J. Insi
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well to be honest, Ernest Friedman-Hill.
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.



Huuuh?
Now I become more confused.


 
J. Insi
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
o gosh....

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.

 
J. Insi
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator



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.


gosh!
 
J. Insi
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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


 
J. Insi
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


he-he-he.
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.

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic