<---- template headericclude ----->
Mingw sockets on w7
FedoraForum.org - Fedora Support Forums and Community
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2010
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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

  2. #2
    Join Date
    Feb 2006
    Posts
    780
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Mingw sockets on w7

    Quote 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

  3. #3
    Join Date
    Aug 2010
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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

  1. mtr: unable to get raw sockets
    By DesiSniper in forum Servers & Networking
    Replies: 4
    Last Post: 20th February 2012, 09:24 PM
  2. Trying to get MinGW working...
    By Stephengp in forum Programming & Packaging
    Replies: 6
    Last Post: 17th June 2009, 06:02 PM
  3. sockets and strings
    By fizy in forum Programming & Packaging
    Replies: 4
    Last Post: 10th May 2008, 10:40 PM
  4. Creating DLL with MinGW GCC
    By pepribal in forum Programming & Packaging
    Replies: 0
    Last Post: 17th November 2007, 10:40 AM
  5. help : install MinGW Studio
    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
  •  
[[template footer(Guest)]]