[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.interop

Any way to create a socket instance for an existing connection?

333

10/24/2007 11:53:00 PM

I'm kinda new at .NET programming so please excuse my ignorance...

I'm trying to use C# to download info from a data service which only has a C
API. Using P/Invoke I've gotten as far as establishing the connection and
sending requests. However, I would like to, as much as possible, use the
..NET functionality for this app hence this question....

So I know my IP address, the port # on which the data server listens and
the socket # for my app's link to the server. With these items, is it
possible for me to create an instance of a System.Net.Sockets.Socket class
and somehow associate it with the connection so that I can then use the .NET
Socket functionality (select, etc.)?

It seemed that the Bind() method might do this, but it asks for the local
endpoint, but I'm not sure how to get this.

Any and all help will be greatly appreciated.

Thanks.

1 Answer

Andrew Faust

10/27/2007 12:09:00 AM

0

Why not just instantiate your own connection instead of trying to hijack an
existing one? If you are trying to bypass the C library then you may as
well not use the library. Besides, even if you do get it working (sorry, I
don't know if it's possible) you messing with the stream would almost
certainly mess up the library you are hijacking anyway.

--
Andrew Faust
andrew[at]andrewfaust.com
http://www.andre...


"333" <333@discussions.microsoft.com> wrote in message
news:14A9C60E-330B-4116-BBEF-971B20349C73@microsoft.com...
> I'm kinda new at .NET programming so please excuse my ignorance...
>
> I'm trying to use C# to download info from a data service which only has
> a C
> API. Using P/Invoke I've gotten as far as establishing the connection
> and
> sending requests. However, I would like to, as much as possible, use the
> .NET functionality for this app hence this question....
>
> So I know my IP address, the port # on which the data server listens and
> the socket # for my app's link to the server. With these items, is it
> possible for me to create an instance of a System.Net.Sockets.Socket
> class
> and somehow associate it with the connection so that I can then use the
> .NET
> Socket functionality (select, etc.)?
>
> It seemed that the Bind() method might do this, but it asks for the local
> endpoint, but I'm not sure how to get this.
>
> Any and all help will be greatly appreciated.
>
> Thanks.
>