Forum > Other

Winsock and OS/2 Strange Issue

<< < (2/4) > >>

Thaddy:

--- Quote from: NeddieSeagoon on February 12, 2024, 07:32:18 pm ---That's a reasonable theory but I live in the UK.

I've checked... Mine starts with 86...

--- End quote ---
Please figure out how that can happen. Are you using a cloud service? It worries me a bit. OS/2 should return a local IP.
If have little or no current knowledge about OS/2 although I used  it in the past.

NeddieSeagoon:
Heh.  I will try to figure it out.  It would be great if someone else who was running OS/2 could give it a try.. I'm running it in Virtualbox.  It's actually this AcraOS ... but it's basically OS/2 4.52.

I used to support it back in the day, when I worked at ASU... but back in the say was 25 years ago, and in Arizona. 

I wonder if there is some sort of ,dll problem... I'll report back.

NeddieSeagoon:
Okay.. I've been playing with this... and I conclude that it is either a bug in PMWsock.dll (unlikely) or more likely, a bug in the FreePascal unit.

Turns out the returned client address is available in Integer format via:

addr.sin_addr.S_addr

And that, in my case, is equal to 16777343...

so, I wrote this procedure (and I hate math):


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- uses  math,sysutils; FUNCTION Ntoa(addr:LONGINT):String;   VAR  IP     : STRING;  I,  octet  : INTEGER;BEGIN  IP := '';  {Loop through the four octets from left to right}  FOR I := 3 downto 0 DO    BEGIN      {shift the address to the right by 8*i bits       and mask the last 8 bits with 255}      octet := (addr shr (8*i)) and 255;       IF I <> 3 THEN        ip := inttostr(octet) + '.' + ip      ELSE        ip := inttostr(octet) + ip;    END;  Ntoa := IP; END; BEGIN  Writeln(Ntoa(16777343));end. 
Which gives me, 127.0.0.1, which is the RIGHT ANSWER.

I don't know who maintains this or how to report a problem?

BTW:  The regular Sockets unit doesn't seem to work right either... but that's another story.

Thaddy:
You should handle the pointer-to-structure, not the structure itself:
This is a pointer type: addr.sin_addr.S_addr

NeddieSeagoon:
Like so?


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  WriteLn('Accepted a connection from ', inet_ntoa(@ClientAddr.sin_addr));  IP := PInteger(@ClientAddr.sin_addr.s_addr)^;  Writeln('NTOA: ',Ntoa(IP)); 
That works (my most recent Pascal programming is from Turbo Pascal 6.  I'm afraid Ruby has damanged my brain.)...

I still get the wrong answer from inet_ntoa and the right answer from my function.  Hmmm...

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version