Advertisement

bad network addresses

Started by November 18, 2000 10:01 AM
3 comments, last by redmonkey 24 years ago
in my game, im using winsock from the source (ie: w/o components) and some machines wont connect. these tend to be win95 machines, although some *do* work. i couldnt find a problem, and eventually traced it back to the server. the ip''s were right, (the address resolved to 192.168.0.x etc) *but* then i noticed the network addresses were negative. those are the ones the server couldnt send packets too. eg: [213.120.28.149] (-1793296171) <-- some guy on net (2k) [192.168.0.150] (-1778341696) <-- win95 on lan [192.168.0.2] (33597632) <-- win2k on lan [127.0.0.1] (16777343) <-- me [213.48.99.89] (1499672789) <-- me through internet those that are negative dont work. can i just use the positive, or is there some sort of incompatibility somewhere? thanks. (the games at www.uberspace.net btw ) __________________ graham "red" reeves. red@deadpenguin.org www.deadpenguin.org
__________________graham "red" reeves.[email=red@deadpenguin.org]red@deadpenguin.org[/email]www.deadpenguin.org
I thought ip address were DWORDs, and hence never negative? did you use a long or an int some where?

how did you determine that they were ''negative''?

192.168.0.0 mask 255.255.0.0 are unroutable IP addresses. No router on the internet is suppose to forward packets to these destinations.

You can''t rely on GetLocalIP functions to give you accurate information. In order to know what IP address an internet machine has, you have to send a connect to a sever, and have it do a GetPeerName to see what IP & Port get you back to that client. Computers with 192.168.x.x IPs are using some form of NAT to connect to the internet (maybe dynamic, maybe static, hard to say).
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
Advertisement
yeah, ive been using int''s to store the ip addresses, but the problem is still there :/ (delphi)

secondly, the 192.xaddress are from the network, and the server can cope with local players *and* ''net player''s at once.

its just some addresses are too high for an int and go negative, just trying to find a decent way to convert back.

__________________
graham "red" reeves.

red@deadpenguin.org
www.deadpenguin.org
__________________graham "red" reeves.[email=red@deadpenguin.org]red@deadpenguin.org[/email]www.deadpenguin.org
can''t you create an unsigned int in Delphi? you probably shouldn''t use int''s for an IP. just typecasting a negative int to a dword (ie unsigned int or unsigned long) should fix it.

IPs are stored LE so if the last segment of the IP address is over 127, it would appear to be negative when viewed as an int.
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
use the "longword" type -- 32 bit unsigned

This topic is closed to new replies.

Advertisement