[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Easy Points: WSADuplicateSocket

Posted on 2004-10-17
3
Medium Priority
?
1,045 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 50 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Loops Section Overview
Screencast - Getting to Know the Pipeline
Suggested Courses

830 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