Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Winsock code - pain in the ass!

Options
  • 02-02-2007 12:23am
    #1
    Closed Accounts Posts: 2,349 ✭✭✭


    I'm having awful troubles trying to do basic things using Winsock. I think I'm switching to a higher level language after this.

    Basically, using Visual Studio Express, if I put include <winsock2.h> in a project I come up with about 200 errors from that file about type redefinition or some bull.

    When I remove it and switch it with #pragma comment( lib, "ws2_32.lib" ) it works fine, as long as the file name is CPP. If I change it to C I will get 20 errors about sockaddr_in not being defined.

    Now I'm trying to create overlapped sockets and it tells me that WSABUF and WSAOVERLAPPED aren't defined even though when i put the mouse over it it shows me the definition

    And MSDN, considering it's taking up 1300MB of my hard disk, it isn't very useful! All of the examples require scouring the net for ages to find out what's going on.


Comments

  • Registered Users Posts: 2,931 ✭✭✭Ginger


    Why not use the System.Net.Sockets libraries rather than importing the old winsock code...


  • Closed Accounts Posts: 1,567 ✭✭✭Martyr


    could you provide output you get? or source code?


  • Closed Accounts Posts: 2,349 ✭✭✭nobodythere


    It's ok I got it. I just confused overlapped sockets with non-blocking sockets and so I was messing with the wrong header files.

    Ginger: I don't even know how to add those classes to use them :/


  • Registered Users Posts: 2,931 ✭✭✭Ginger


    In managed C++ you can use
    using System::Net::Sockets
    

    Unless you are using Visual Studio Express for something else other than managed C++


  • Closed Accounts Posts: 2,349 ✭✭✭nobodythere


    I was just doing it the hardcore API style. Which gets really frustrating. This managed C++ thing seems like a great help, particularly cos I can't get the hang of using MFC (it just looks so bloated or something!). Thanks


  • Advertisement
Advertisement