hi,
I work on a computer that is part of a network and uses proxy to connect to net. I cant connect to servers outside my proxy with simple ConnectTo code. I need to know how to make my requests go through proxy. eg,
_socket = new TcpClient("http://msdn.microsoft.com", port);
does not work.
Thanx.
Ab. 10 24531
Hi Abubakar,
I'm not good i .NET network stuff, but...
The TcpClient constructor needs a "host name"
(e.g. "msdn.microsoft.com"), not a WWW address.
Regards
Marcin hi, I work on a computer that is part of a network and uses proxy to connect to net. I cant connect to servers outside my proxy with simple ConnectTo code. I need to know how to make my requests go through proxy. eg, _socket = new TcpClient("http://msdn.microsoft.com", port); does not work. Thanx. Ab.
From MSDN: If your site uses a proxy to provide access to the Internet, you must configure a proxy instance to enable your application to communicate with the Web proxy. The following code example creates a global proxy instance that will enable any WebRequest to use a proxy to communicate with the Internet. The example assumes that the proxy server is named webproxy and that it communicates on port 80, the standard HTTP port.
[C#] WebProxy proxyObject = new WebProxy("http://webproxy:80/"); GlobalProxySelection.Select = proxyObject;
You can override the global proxy selection by assigning an instance that implements the IWebProxy interface to the Proxy property of your WebRequest. The following code example sends a WebRequest to www.contoso.com that overrides the global proxy selection with a proxy server named alternateproxy on port 80. [C#] WebRequest req = new WebRequest.Create("http://www.contoso.com/"); req.Proxy = new WebProxy("http://alternateproxy:80/");
Look at the following topics:
- HTTP
- Accessing the Internet Through a Proxy
Have Fun!
Martin
Abubakar wrote:
hi, I work on a computer that is part of a network and uses proxy to connect to net. I cant connect to servers outside my proxy with simple ConnectTo code. I need to know how to make my requests go through proxy. eg, _socket = new TcpClient("http://msdn.microsoft.com", port); does not work. Thanx. Ab.
I dont want to use WebRequest,,, I want to use TCPClient.
"mphanke" wrote: From MSDN:
If your site uses a proxy to provide access to the Internet, you must configure a proxy instance to enable your application to communicate with the Web proxy. The following code example creates a global proxy instance that will enable any WebRequest to use a proxy to communicate with the Internet. The example assumes that the proxy server is named webproxy and that it communicates on port 80, the standard HTTP port.
[C#] WebProxy proxyObject = new WebProxy("http://webproxy:80/"); GlobalProxySelection.Select = proxyObject;
You can override the global proxy selection by assigning an instance that implements the IWebProxy interface to the Proxy property of your WebRequest. The following code example sends a WebRequest to www.contoso.com that overrides the global proxy selection with a proxy server named alternateproxy on port 80. [C#] WebRequest req = new WebRequest.Create("http://www.contoso.com/"); req.Proxy = new WebProxy("http://alternateproxy:80/");
Look at the following topics:
- HTTP - Accessing the Internet Through a Proxy
Have Fun!
Martin
Abubakar wrote:
hi, I work on a computer that is part of a network and uses proxy to connect to net. I cant connect to servers outside my proxy with simple ConnectTo code. I need to know how to make my requests go through proxy. eg, _socket = new TcpClient("http://msdn.microsoft.com", port); does not work. Thanx. Ab.
You will have to use TcpClient to connect to your proxy, and send the
correct http request packet to get the data.
However, why do you want to reinvent the wheel ? Why dont you wnat to use
HttpWebRequest ? Remember if you use TcpClient/Socket to do this, you will
also have to parse the returned Http response yourself.
feroze
======================
This posting is provided as-is. It offers no warranties and confers no
rights.
"Abubakar" <Ab******@discussions.microsoft.com> wrote in message
news:EB**********************************@microsof t.com... hi, I work on a computer that is part of a network and uses proxy to connect
to net. I cant connect to servers outside my proxy with simple ConnectTo
code. I need to know how to make my requests go through proxy. eg, _socket = new TcpClient("http://msdn.microsoft.com", port); does not work. Thanx. Ab.
Abubakar wrote: here is an example: I create a simple server, at my *home*, in C# using the Net classes to listen at some port say P. I create a client sitting in my *office* (office pc:which uses proxy for accessing internet) and i want to connect to my home listening tcp server at IP say X. Now how do I use http, which I dont want here I guess (i may be wrong), to connect at ip X at port P? Can that be done with httpwebrequest? Or should it be done with httpwebrequest?
Well, what's the application supposed to be doing? Why implement a custom
protocol on top of TCP/IP? Unless you're doing some really high-endish
stuff, HTTP should do the trick easily.
Cheers,
--
Joerg Jooss jo*********@gmx.net
I think I really am not understanding you guys, and now confused because you guys sound so obvious in what you are saying. I need your guidance now. Lets see. I'm on a office network and have to write a program which will connect to an app listening in my home PC on the internet and after connection I just want to send it a message say "hello net!". How do I do this? Just tell me the steps and classes to use.
Ab.
"Joerg Jooss" wrote: Abubakar wrote: here is an example: I create a simple server, at my *home*, in C# using the Net classes to listen at some port say P. I create a client sitting in my *office* (office pc:which uses proxy for accessing internet) and i want to connect to my home listening tcp server at IP say X. Now how do I use http, which I dont want here I guess (i may be wrong), to connect at ip X at port P? Can that be done with httpwebrequest? Or should it be done with httpwebrequest?
Well, what's the application supposed to be doing? Why implement a custom protocol on top of TCP/IP? Unless you're doing some really high-endish stuff, HTTP should do the trick easily.
Cheers,
-- Joerg Jooss jo*********@gmx.net
Abubakar wrote: I think I really am not understanding you guys, and now confused because you guys sound so obvious in what you are saying. I need your guidance now. Lets see. I'm on a office network and have to write a program which will connect to an app listening in my home PC on the internet and after connection I just want to send it a message say "hello net!". How do I do this? Just tell me the steps and classes to use.
Well, if all you want to do is get a basic understanding of client/server
network programming, both System.Net.Sockets.Socket and
TcpClient/TcpListener will do the trick. But is this your whole application?
Being able to send a plain text message?
Cheers,
--
Joerg Jooss jo*********@gmx.net
now we are getting somewhere.
You see you have mentioned "TcpClient/TcpListener" yourself. I have made pretty nice multiclient, rooms enabled, multi-threaded chat apps before as experiments, so I have the basic understanding of the client-server applications. Now I'v been doing that by using classes that you mentioned which are "TcpClient/TcpListener" and others like networkstream etc. But one of the app that I was trying to make which would enable me to be in contact with my home pc anywhere I go, through my mobile or through a desktop pc. I'm making the desktop version in C# and *will* make the mobile version in Java :( cuz the mobile I got uses a symbian OS and no .net is available for that.
Anyway, so I use the TcpClient to make a connection at an IP say x.x.x.x, but my problem was, due to which i started this thread, that I'm on a network and the ip that I give for connection is alway *not found* or *host unreachable* becuz ofcourse I'm on a network and directly mentioning, inside the network, an IP which is outside the network is not found. So now I needed a way through which my tcplient becomes intelligent enough to automatically resolve that IP through the proxy, but it doesnt.
And in turn everyone started telling me to use httpwebrequest, and I'm like "how does this httwebrequest came into discussion?"
So the question remains.
Ab.
"Joerg Jooss" wrote: Abubakar wrote: I think I really am not understanding you guys, and now confused because you guys sound so obvious in what you are saying. I need your guidance now. Lets see. I'm on a office network and have to write a program which will connect to an app listening in my home PC on the internet and after connection I just want to send it a message say "hello net!". How do I do this? Just tell me the steps and classes to use.
Well, if all you want to do is get a basic understanding of client/server network programming, both System.Net.Sockets.Socket and TcpClient/TcpListener will do the trick. But is this your whole application? Being able to send a plain text message?
Cheers, -- Joerg Jooss jo*********@gmx.net
In article <0C**********************************@microsoft.co m>, Ab******@discussions.microsoft.com says... now we are getting somewhere. You see you have mentioned "TcpClient/TcpListener" yourself. I have made pretty nice multiclient, rooms enabled, multi-threaded chat apps before as experiments, so I have the basic understanding of the client-server applications. Now I'v been doing that by using classes that you mentioned which are "TcpClient/TcpListener" and others like networkstream etc. But one of the app that I was trying to make which would enable me to be in contact with my home pc anywhere I go,
through my mobile or through a desktop pc. I'm making the desktop version in C# and *will* make the mobile version in Java :( cuz the mobile I got uses a symbian OS and no .net is available for that. Anyway, so I use the TcpClient to make a connection at an IP say x.x.x.x, but my problem was, due to which i started this thread, that I'm on a network and the ip that I give for connection is alway *not found* or *host unreachable* becuz ofcourse I'm on a network and directly mentioning, inside the network, an IP which is outside the network is not found. So now I needed a way through which my tcplient becomes intelligent enough to automatically resolve that IP through
the proxy, but it doesnt. And in turn everyone started telling me to use httpwebrequest, and I'm like "how does this httwebrequest came into discussion?" So the question remains.
Ab.
"Joerg Jooss" wrote:
Abubakar wrote: I think I really am not understanding you guys, and now confused because you guys sound so obvious in what you are saying. I need your guidance now. Lets see. I'm on a office network and have to write a program which will connect to an app listening in my home PC on the internet and after connection I just want to send it a message say "hello net!". How do I do this? Just tell me the steps and classes to use.
Well, if all you want to do is get a basic understanding of client/server network programming, both System.Net.Sockets.Socket and TcpClient/TcpListener will do the trick. But is this your whole application? Being able to send a plain text message?
Cheers, -- Joerg Jooss jo*********@gmx.net
Hi,
take a look to the thread with the same name, started by Wal Turner on
Jul 29.
Sunny
Abubakar wrote: now we are getting somewhere. You see you have mentioned "TcpClient/TcpListener" yourself. I have made pretty nice multiclient, rooms enabled, multi-threaded chat apps before as experiments, so I have the basic understanding of the client-server applications. Now I'v been doing that by using classes that you mentioned which are "TcpClient/TcpListener" and others like networkstream etc. But one of the app that I was trying to make which would enable me to be in contact with my home pc anywhere I go, through my mobile or through a desktop pc. I'm making the desktop version in C# and *will* make the mobile version in Java :( cuz the mobile I got uses a symbian OS and no .net is available for that.
Note: You should post your problem to a networking group, like
comp.os.ms-windows.networking.tcp-ip or
microsoft.public.windowsxp.network_web. This is more a problem of setting up
your infrastructure.
Anyway, so I use the TcpClient to make a connection at an IP say x.x.x.x, but my problem was, due to which i started this thread, that I'm on a network and the ip that I give for connection is alway *not found* or *host unreachable* becuz ofcourse I'm on a network and directly mentioning, inside the network, an IP which is outside the network is not found.
So I guess you're talking about a home LAN that is connected to the Internet
by some broadband router performing NAT?
So now I needed a way through which my tcplient becomes intelligent enough to automatically resolve that IP through the proxy, but it doesnt.
Your client would talk to the proxy, which in turn talks to the real
application server. A proxy does not resolve addresses for the public. But
anyway, you'll need some network component that is permanently visible on
the Internet, for example by using DynDNS with a compatible router. You
could either expose your server directly (not a good idea) or use a proxy.
Cheers,
--
Joerg Jooss jo*********@gmx.net This discussion thread is closed Replies have been disabled for this discussion. Similar topics
3 posts
views
Thread by מורדי |
last post: by
|
5 posts
views
Thread by Wal Turner |
last post: by
|
reply
views
Thread by Evan Freeman[C++ Samuri] |
last post: by
|
4 posts
views
Thread by WATYF1 |
last post: by
|
5 posts
views
Thread by Jim W |
last post: by
|
reply
views
Thread by Tamas Bojcan |
last post: by
|
6 posts
views
Thread by Julien |
last post: by
|
reply
views
Thread by aladdinm1 |
last post: by
|
4 posts
views
Thread by Peter |
last post: by
| | | | | | | | | | |