Fedora Linux Support Community & Resources Center
  #1  
Old 22nd November 2010, 05:31 AM
tristen Offline
Registered User
 
Join Date: Aug 2010
Posts: 16
windows_xp_2003chrome
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
Reply With Quote
  #2  
Old 22nd November 2010, 03:30 PM
David Becker Offline
Registered User
 
Join Date: Feb 2006
Posts: 780
linuxfedorafirefox
Re: Mingw sockets on w7

Quote:
Originally Posted by tristen View Post
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
Reply With Quote
  #3  
Old 23rd November 2010, 01:29 AM
tristen Offline
Registered User
 
Join Date: Aug 2010
Posts: 16
windows_xp_2003chrome
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
Reply With Quote
Reply

Tags
mingw, sockets

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
mtr: unable to get raw sockets DesiSniper Servers & Networking 4 20th February 2012 08:24 PM
Trying to get MinGW working... Stephengp Programming & Packaging 6 17th June 2009 06:02 PM
sockets and strings fizy Programming & Packaging 4 10th May 2008 10:40 PM
Creating DLL with MinGW GCC pepribal Programming & Packaging 0 17th November 2007 09:40 AM
help : install MinGW Studio Edems Installation, Upgrades and Live Media 1 17th November 2006 06:14 AM


Current GMT-time: 11:37 (Tuesday, 02-09-2014)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat