Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Easy Points: WSADuplicateSocket

Posted on 2004-10-17
3
Medium Priority
?
1,026 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: 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…
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…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

636 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