Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

bind() binds server socket with local IPv6/Port....How Can I Make It bind() on IPv4?

I got a weird problem. I coded a server. Works good, but it only binds the port to the local IPv6 .... So when the client enters the target external IP (Usually IPv4)/port. Client will be able to connect to the listening port that is through IPv4 only...

For example, i made my server binds on port 4443 on the local machine...

I check netstat -an, i get

Proto Local Address Foreign Address State
TCP 0.0.0.0:135 0.0.0.0:0 LISTENING
TCP 0.0.0.0:445 0.0.0.0:0 LISTENING
TCP 0.0.0.0:1025 0.0.0.0:0 LISTENING
TCP [::]:135 [::]:0 LISTENING
TCP [::]:445 [::]:0 LISTENING
TCP [::]:1025 [::]:0 LISTENING
TCP [::]:4443 [::]:0 LISTENING

ports 135, 445, and 1025 will respond to client who connects to it through IPv4 or IPv6. 4443 will only respond to client who connects to it through IPv6. So for a client to connect on the server port 4443, it (client) must enter IPv6 for the target so 4443 can respond. Otherwise, connection will fail as you see that 4443 is not included among IPv4! I hope you get my point.....Weird problem! ..... On linux, everything works fine, but on Vista things did not go as it should be....

I hope somebody can provide some help...

Hey, if you don't understand what i have written, lemme know. I will try to re-explain it...
(Nov 8, 2008 11:33 PM)ʇsıʎqqoɥ Wrote:  I got a weird problem. I coded a server. Works good, but it only binds the port to the local IPv6 .... So when the client enters the target external IP (Usually IPv4)/port. Client will be able to connect to the listening port that is through IPv4 only...

For example, i made my server binds on port 4443 on the local machine...

I check netstat -an, i get

Proto Local Address Foreign Address State
TCP 0.0.0.0:135 0.0.0.0:0 LISTENING
TCP 0.0.0.0:445 0.0.0.0:0 LISTENING
TCP 0.0.0.0:1025 0.0.0.0:0 LISTENING
TCP [::]:135 [::]:0 LISTENING
TCP [::]:445 [::]:0 LISTENING
TCP [::]:1025 [::]:0 LISTENING
TCP [::]:4443 [::]:0 LISTENING

ports 135, 445, and 1025 will respond to client who connects to it through IPv4 or IPv6. 4443 will only respond to client who connects to it through IPv6. So for a client to connect on the server port 4443, it (client) must enter IPv6 for the target so 4443 can respond. Otherwise, connection will fail as you see that 4443 is not included among IPv4! I hope you get my point.....Weird problem! ..... On linux, everything works fine, but on Vista things did not go as it should be....

I hope somebody can provide some help...

oh come now, thats just gibberish! have some scones :)

*EDIT actuly i get it now... the monkey goes in the blender!
the question could be dummy, but am i'm too exhausted, so am blank now. Anyhow, i will be looking at it tomorrow...But, if you got the answer and you think its simple, post it, dont just say blah blah & leave...
I figured it out. I had to change hints.ai_family = AF_UNSPEC; to hints.ai_family = AF_INET;
As AF_UNSPEC, picks the highest numbered family protocol which happens to be IPV6 with Windows. I don't know why in Windows Vista let my application binds the port with IPV6 only. On other hand, linux binds the port with both IP versions. Anyhow, since IPv4 is more common, i just forced the ai_family to be AF_INET - IPv4 ...


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Assembly] by arun hackerJan 20, 2017 05:52 PM 8 511 Jan 20, 2017 05:52 PM
Last Post: CPLUSPLUSBOTNET
[Delphi] by charmeurJul 10, 2016 01:56 AM 0 277 Jul 10, 2016 01:56 AM
Last Post: charmeur
[Perl] by Johndoe27328May 13, 2013 06:00 PM 1 221 May 13, 2013 06:00 PM
Last Post: Rozyn