Solved

Easy Points: WSADuplicateSocket

Posted on 2004-10-17
3
963 Views
Last Modified: 2010-05-18

I have serach for a example on how to use WSADuplicateSocket with Delphi v6, but I have not found any!  The msdn examle is in c and I don't know how to convert c examples into delphi.

So, if ya'll could be so kind as to post a simple example on how to use WSADuplicateSocket with Delphi v6.

0
Comment
Question by:RenegadeBBS
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
LMuadDIb earned 25 total points
ID: 12333676
sorry I cant help with an example of using WSADuplicateSocket with Delphi v6
but I did notice most of the results I got from google concerning WSADuplicateSocket & Delphi were from websites from russia
and if no one can supply an example for you, I would try translating some of those russian websites with http://world.altavista.com/babelfish/tr
russian>>english

its a pain, and you might not get correct translation, but I have been known to use this method myself once in a while =)
^ENuD
0
 
LVL 1

Author Comment

by:RenegadeBBS
ID: 12334816
{using winsock 2.2 api}

uses winsock2;
var
   ProtoInfo : TWSAProtocol_Info;
   IncomingSocket : TSocket;
   ThreadSocket    : TSocket;
begin
    WinSock2.WSADuplicateSocket(InComingSocket,GetCurrentProcessID,@ProtoInfo);
    ThreadSocket := WinSock2.WSASocket(AF_INET, SOCK_STREAM, IPPROTO_IP, @ProtoInfo, 0, WSA_FLAG_OVERLAPPED);
end;

Finally Finally worked it out!

The translators turned all the russian pages to ?? marks and pretty much told me what msdn was saying, but with alot less info, but I'll accept the answer, because.. #1 forgot I had only return english results check for google.  After setting
to search all lang's.  I saw some of those russian sites.  Loaded one.  Turn bebel fish on it.  All the ?, but the delphi stuff was in english.  So.. What startted me on finding this out was.. look at this structure on the russian website.

function WSADuplicateSocket(
      S:TSocket;
      dwProcessID:DWORD;
      var ProtocolInfo:TWSAProtocolInfo):Integer;
Then just googling how to do. dwProcessID and TWSAPotocolinfo. and I was set, but then had to do a wsasocket to finalize the code. but anyhow.. :)  The bad part it still doesn't do what it should though.  The code is right, but createprocess isn't allowing the socket handle to be inheritted by the calling app on winxp.. win98se..me..2k works, but xp is having trouble!  ahh.. and I thought wsaduplicatesocket would cure this.. nope!

thanks..
0
 
LVL 1

Author Comment

by:RenegadeBBS
ID: 13083636
follow up:  found out it was the .net framework with the Q.o.S. protocol screwing with the socket calls and passing of the security flag that was blocking the calling app from getting proper access to the socket handle.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question