Board index » delphi » Indy 8.004 bug applying 32 bit value to winsock 16 bit causing range check error

Indy 8.004 bug applying 32 bit value to winsock 16 bit causing range check error

Hello,

in the file IdStackWinsock, within the function:

function TIdStackWinsock.WSBind(ASocket: TIdStackSocketHandle;
  const AFamily: Integer; const AIP: string;
  const APort: Integer): Integer;

look at line 125:
  Addr.sin_port := HToNS(APort);

According to the documentation, HToNS expects a u_short (16 bits), and here
it is fed by APort: Integer (32 bits).
It caused a Range Check Error exception being thrown when I give it
something that exceeds the 16 bits value. e.g. IdUDPClient1.Port := 320000;

This "bug" is quite deep and needs a lot of change (a lot of conversion from
Integer to SmallInt or Word (u decide).

Or is there any other reason for this?

Please consider turning on all the debug warning and checks on a test build.

 

Re:Indy 8.004 bug applying 32 bit value to winsock 16 bit causing range check error


Accckkkk

I noticed TClientSocket / TServerSocket (from Borland) also uses Integer for
their port properties.

I guess I can't win in this case :)

Re:Indy 8.004 bug applying 32 bit value to winsock 16 bit causing range check error


[email protected] (Jimmy H) wrote in <[email protected]>:

Quote
>Please consider turning on all the debug warning and checks on a test build.

All warnings are on in our build.

Ports are in fact short ints - but with the conversion to Winsock32 the call
may expect integers. Id have to double check.

But I know that as far as TCP is concerned, you can only use 16 bit values.

--
Chad Z. Hower (Kudzu) - Church Hill, TN - Team Indy
      "Programming is an art form that fights back"
Forget the Y2K problem, Lets fix the W2K problem.
http://www.pbe.com/Kudzu/ - Free Delphi/CBuilder components and articles

Other Threads