Solved

Easy Points: WSADuplicateSocket

Posted on 2004-10-17
3
948 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

708 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now