HighTechTalks DotNet Forums  

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

Dotnet Framework (Interop) microsoft.public.dotnet.framework.interop


Discuss Any way to create a socket instance for an existing connection? in the Dotnet Framework (Interop) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
333
 
Posts: n/a

Default Any way to create a socket instance for an existing connection? - 10-24-2007 , 07:53 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.


Reply With Quote
  #2  
Old   
Andrew Faust
 
Posts: n/a

Default Re: Any way to create a socket instance for an existing connection? - 10-26-2007 , 08:08 PM






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.andrewfaust.com


"333" <333 (AT) discussions (DOT) microsoft.com> wrote

Quote:
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.



Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.