-
22nd November 2010, 06:31 AM
#1
Mingw sockets on w7
hello!
i'm cross-compiling a program that uses berkeley-style sockets.
all compiles well, but the data structures for sockaddr and sockaddr_in all seem to be a bit screwy when i run the same code on windows 7. this results in the wrong ip addresses being translated from getaddrinfo and friends, particularly in translating a host name into a binary address and ultimately to a text ip address.
so...it took me a bit searching to work out that the data structures on xp and windows 7 differ. i couldn't find anything specific unfortunately, just the fact that they do.
has anyone else had the same problemo and how did they solve it?
cheers
tristen
-
22nd November 2010, 04:30 PM
#2
Re: Mingw sockets on w7
Originally Posted by
tristen
hello!
i'm cross-compiling a program that uses berkeley-style sockets.
all compiles well, but the data structures for sockaddr and sockaddr_in all seem to be a bit screwy when i run the same code on windows 7. this results in the wrong ip addresses being translated from getaddrinfo and friends, particularly in translating a host name into a binary address and ultimately to a text ip address.
so...it took me a bit searching to work out that the data structures on xp and windows 7 differ. i couldn't find anything specific unfortunately, just the fact that they do.
It sounded like a case of host/net order mismatch. Maybe this helps: http://msdn.microsoft.com/en-us/libr...=VS.85%29.aspx
David
-
23rd November 2010, 02:29 AM
#3
Re: Mingw sockets on w7
cheers david, that link made me think "it has to be a bug in my code" and lo, it turned out to be a bug in my code.
some gory details that may help someone else:
i had a pointer to a sockaddr_in structure in an addrinfo list returned by getaddrinfo. I subsequently freed the addrinfo structure (using freeaddrinfo). I continued to use the pointer to the sockaddr_in despite the fact that i'd freed the addrinfo structure. This is of course undefined behaviour.
xp __seemed__ to be ok about it the several dozen times i'd tested, but w7 100% of the time wasn't. I dunno and don't care how vista feels about it
Similar Threads
-
By DesiSniper in forum Servers & Networking
Replies: 4
Last Post: 20th February 2012, 09:24 PM
-
By Stephengp in forum Programming & Packaging
Replies: 6
Last Post: 17th June 2009, 06:02 PM
-
By fizy in forum Programming & Packaging
Replies: 4
Last Post: 10th May 2008, 10:40 PM
-
By pepribal in forum Programming & Packaging
Replies: 0
Last Post: 17th November 2007, 10:40 AM
-
By Edems in forum Installation, Upgrades and Live Media
Replies: 1
Last Post: 17th November 2006, 07:14 AM
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
[[template footer(Guest)]]