Jump to content
Sign in to follow this  
limelect

socket error 11004

Recommended Posts

I have these lines of code where s is the name of the computer I want to find its IP

 

   TIdStack.IncUsage;
  try

    s := GStack.ResolveHost(s);
 Panel4.Caption:= s2+' IP - '+s;
  finally
    TIdStack.DecUsage;
  end;


 The first time it is OK

The second time it gives me an error  11004

Any fix? D10.2.3 Indy 10

 

Plz only real answer no blabla

 

P.S Debugging I reached unit IdWship6; where I am stack

I am working with UDP

Edited by limelect

Share this post


Link to post

I have to clarify what I do the first time is to find all computers on the net with

 

procedure EnumNetwork(const aEnumNetworkProc :TEnumNetworkProc; const aScope :dword = RESOURCE_GLOBALNET; const aType :dword = RESOURCETYPE_ANY);

implementation

//Proc?dure r?cursive
procedure DoEnumNetwork(const aContainer :Pointer;
                        const aEnumNetworkProc :TEnumNetworkProc;
                        const aScope :dword;
                        const aType  :dword;
                        const aLevel :byte);
type
  PNetResourceArray = ^TNetResourceArray;
  TNetResourceArray = array [0..0] of TNetResource;
var
  NetHandle    :THandle;
  NetResources :PNetResourceArray;
  NetResult    :dword;
  Size, Count, i :Cardinal;
  Continue     :boolean;
begin
  Continue := TRUE;

  NetResult := WNetOpenEnum(aScope, aType, 0, aContainer, NetHandle);

  if NetResult = NO_ERROR then
  try
    //Taille de base
    Size := 50 *SizeOf(TNetResource);
    GetMem(NetResources, Size);

    try
      while Continue do
      begin
        Count := $FFFFFFFF;
        NetResult := WNetEnumResource(NetHandle, Count, NetResources, Size);

        //Taille insuffisante ?
        if NetResult = ERROR_MORE_DATA
        then ReallocMem(NetResources, Size)
        else Break;
      end;

      //Enum?re
      if NetResult = NO_ERROR then
        for i := 0 to Count - 1 do
        begin
          //Callback
          if Assigned(aEnumNetworkProc) then
          begin
            aEnumNetworkProc(NetResources^, aLevel, Continue);
            if not Continue then Break;
          end;

          //Appel r?cursif
          if (NetResources^.dwUsage and RESOURCEUSAGE_CONTAINER) > 0 then 
            DoEnumNetwork(@NetResources^, aEnumNetworkProc, aScope, aType, aLevel +1);
        end;
    finally
      FreeMem(NetResources, Size);
    end;
  finally
    WNetCloseEnum(NetHandle);
  end;
end;

 

Then I find the computer IP once but second time an error

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×