473,395 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

tcpclients between browser and internet

Hi all,

i am trying to create a small app which can record the requests from
and responses to my browser.

To achieve this i am using two tcpclients and a listener.
The first 1 is listening to a port on my localhost to intercept the
browsers request. The second 1 uses the stream of tcpclient1 and
forwards it to the target.
The response-stream from the target is read from tcpclient2 and
written to tcpclient1.

Seems workable. And when i step through the code using <shift><f8>, it
works fine indeed.
However, when i don't use breakpoints, the requests and responses seem
somewhat confused. The rendering in my browser is not what one would
expect :-).

I tried application.doevents, setting the sendtimeout on the
tcpclient, but both offers no solution.

2nd strange thing is that i can only go to one destination. After
that, the tcp-listener seems to ignore most requests.

I'll post my code (which of course is only for testing purposes and
doesnt deserve a price for efficient coding (yet)) below.

Thanks for your remarks.

grtz,

mark

<code>
Dim ipAddress As IPAddress = ipAddress.Parse("127.0.0.1")

_listener = New TcpListener(ipAddress, 7090)
_listener.Start()

While True
Dim client As TcpClient
client = _listener.AcceptTcpClient

Dim stream As NetworkStream = client.GetStream()
Dim buffer(4096) As Byte

stream.Read(buffer, 0, buffer.Length)
Dim data As String =
System.Text.Encoding.ASCII.GetString(buffer, 0, buffer.Length)

Dim url As String = GetUrl(data)
Dim clientForward As TcpClient = New TcpClient(url, 80)
clientForward.SendTimeout = 3000

Dim streamOut As NetworkStream = clientForward.GetStream

streamOut.Write(buffer, 0, buffer.Length)
Application.DoEvents()
streamOut.Read(buffer, 0, buffer.Length)

stream.Write(buffer, 0, buffer.Length)
stream.Close()
client.Close()

If Not stream.CanRead Then
streamOut.Close()
clientForward.Close()
End If
End While

<end code>
Jul 21 '05 #1
0 1018

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: www | last post by:
I have seen an example of a page that displays the users browser details in a friendly manner like this: Your operating system : Microsoft Windows NT Your browser : Microsoft Internet Explorer...
11
by: Simon Wigzell | last post by:
I cobbled together the following function from examples on the internet to set named spanned items in the parent form. It works fine for IE but not at all for netscape. What other browser...
13
by: Kai Grossjohann | last post by:
It seems that Ctrl-N in Mozilla opens a new empty browser window. That's fine, I don't need to do anything about it. But Ctrl-N in IE appears to clone the current window. Is there a way to...
34
by: Charles Douglas Wehner | last post by:
This is a serious question - but probably one that has been asked many times before. Go to http://wehner.org It has FRAMES. Select ADDISON. The main page (to the right of the buttons) shows...
17
by: lawrence | last post by:
How is it possible that the question "How do I detect which browser the user has" is missing from this FAQ: http://www.faqts.com/knowledge_base/index.phtml/fid/125 and is only here on this...
17
by: Mark Rae | last post by:
Hi, I'm interested in your opinion concerning how far you would consider it necessary to code for cross-browser compatibility these days, especially for public-facing Internet sites... ...
1
by: Jerry Spence1 | last post by:
I am currently looking at writing a TCP client for talking to a number of networked card readers. With Vb.Net, the process hangs pending an input. To overcome this problem I am using the ThreadPool...
0
by: Mark | last post by:
Hi all, i am trying to create a small app which can record the requests from and responses to my browser. To achieve this i am using two tcpclients and a listener. The first 1 is listening to...
7
by: Nathan Sokalski | last post by:
I want to make sure I am doing a browser detection that will work once IE7 is released. My current detection statement (written using VB.NET) is: If Me.Request.Browser.Browser.ToUpper() = "IE"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.