Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Looking for an example of System.Net

0 views
Skip to first unread message

Thanh Nguyen

unread,
Nov 14, 2000, 9:48:26 PM11/14/00
to
Hi Josh,
With Wininet, I would first connect to a site, then use HttpOpenRequest() to
ask
for some page in that site :

hdl = InternetOpen(...) ;
session = InternetConnect(hdl, "www.somesite.com", port, ...) ;
req = HttpOpenRequest(session, "POST", "page1.asp", ...);

With System.Net, I would do the following:

HttpWebRequest req = (HttpWebRequest)
WebRequestFactory.Create(www.somesite.com);
WebResponse resp = req.GetResponse();

The System.Net does not have the notion of session.
Does that means that the session is implicitly kept if I stay in the site ?

Could you show me some code equivalent tot he Wininet fragment above?

Thanks,
tom.


"Josh" <joshr...@yahoo.com> wrote in message
news:#UDdKMkTAHA.174@cppssbbsa04...
> The use is very similar....tell me what you are exactly trying to
accomplish
> and I'll show you in C# how to do it.
>
> --
> Sincerely,
>
> Josh Mitts
> joshr...@yahoo.com
> ICQ: 77964060
>
>
> "Thanh Nguyen" <tom...@sympatico.ca> wrote in message
> news:ON#Z9rdTAHA.76@cppssbbsa05...
> > Hi,
> > I wrote a search engine using Wininet.
> > Now I would like to port it to the .Net framework.
> >
> > Is there a site that shows a sample ?
> > (I saw the one posted on the msdn dotnet site.
> > But it is rather too basic).
> >
> > thanks in advance.
> > tom.
> >
> >
>
>


Josh Mitts

unread,
Nov 15, 2000, 9:13:25 AM11/15/00
to
Hey :)

OK, first of all, I am not totally sure why you would want to keep the
session alive (remember, HTTP is a session-less protocal)...but here's one
implementation using a Stream:

HttpWebRequest req = (HttpWebRequest)
WebRequestFactory.Create("www.microsoft.com");
HttpWebResponse resp = req.GetResponse();
resp.GetResponseStream(); // provides a stream object which can be used to
access the data in a stream

To go beyond that and use a Socket connection to the server like you do in
WinInet, that's a whole different ball of wax, but I think it is what you
are trying to accomplish. To begin, take a look at the System.Net.Sockets
class. That contains all of the underlying classes to allow direct socket
connections to servers. The one you will probobly use is
System.Net.Sockets.TCPClient. For example:

TCPClient tc = new TCPClient("www.microsoft.com", 80);
tc.Connect();
NetworkStream myStream = tc.GetStream();
myStream.BeginRead(...); // and other NetworkStream methods, etc.

Hope that helps!


--
Sincerely,

Josh Mitts
joshr...@yahoo.com
ICQ: 77964060

*** Please reply in the newsgroup, I am unable to answer any e-mail
questions. Thanks! ***

"Thanh Nguyen" <tom...@sympatico.ca> wrote in message

news:#Be8QZrTAHA.243@cppssbbsa03...

Thanh Nguyen

unread,
Nov 15, 2000, 10:13:09 PM11/15/00
to
I need a session in order for the session cookie.
(without it you cannot have session cookies).

I guess that the simplest would be to write a test program.
I will post my result, unless somebody responded before.

thanks Josh.

"Josh Mitts" <joshr...@yahoo.com> wrote in message
news:uFN59zwTAHA.278@cppssbbsa03...

Josh Mitts

unread,
Nov 16, 2000, 9:10:30 AM11/16/00
to
No problem :)

--
Sincerely,

Josh Mitts
joshr...@yahoo.com
ICQ: 77964060

*** Please reply in the newsgroup, I am unable to answer any e-mail
questions. Thanks! ***

"Thanh Nguyen" <tom...@sympatico.ca> wrote in message

news:uRUGvL4TAHA.196@cppssbbsa04...

0 new messages