Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Including winsock2.h problem

Including winsock2.h problem

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpgraphicsgame-devtutorial
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Budric B
    wrote on last edited by
    #1

    Hi, I have a project I'm working on using GLUT, openGL and a few libraries. Now I'm trying to add sockets to it and whenever I include winsock2.h (haven't even written any relevant code) syntax error : ',' at some line which is meaningless appears. The code compiles and runs if I don't include winsock2.h I'm using VC++ 2005. I have ws2_32.lib set up to link. I'm not including windows.h, MFC support. I just can't figure out what's wrong. Example code for winsock compiles and works. As an aside can anyone point to a cross platform sockets library? I think GTK has one but it's way too big.

    B M 2 Replies Last reply
    0
    • B Budric B

      Hi, I have a project I'm working on using GLUT, openGL and a few libraries. Now I'm trying to add sockets to it and whenever I include winsock2.h (haven't even written any relevant code) syntax error : ',' at some line which is meaningless appears. The code compiles and runs if I don't include winsock2.h I'm using VC++ 2005. I have ws2_32.lib set up to link. I'm not including windows.h, MFC support. I just can't figure out what's wrong. Example code for winsock compiles and works. As an aside can anyone point to a cross platform sockets library? I think GTK has one but it's way too big.

      B Offline
      B Offline
      Budric B
      wrote on last edited by
      #2

      Found the problem, I called one of my variables "far" which turns out to be #defined somewhere Still open to suggestions on portable socket library. I just don't want to mess around with it.

      1 Reply Last reply
      0
      • B Budric B

        Hi, I have a project I'm working on using GLUT, openGL and a few libraries. Now I'm trying to add sockets to it and whenever I include winsock2.h (haven't even written any relevant code) syntax error : ',' at some line which is meaningless appears. The code compiles and runs if I don't include winsock2.h I'm using VC++ 2005. I have ws2_32.lib set up to link. I'm not including windows.h, MFC support. I just can't figure out what's wrong. Example code for winsock compiles and works. As an aside can anyone point to a cross platform sockets library? I think GTK has one but it's way too big.

        M Offline
        M Offline
        Matthew Faithfull
        wrote on last edited by
        #3

        I expect you probably need to include windows.h before winsock2.h. If you're looking for a cross platform sockets library I'd start with BSD sockets, probably in netBSD these days. It's where Microsoft started when they needed to 'source' a socket implementation for Win95 or so the rumour goes. ;)

        Nothing is exactly what it seems but everything with seems can be unpicked.

        B 1 Reply Last reply
        0
        • M Matthew Faithfull

          I expect you probably need to include windows.h before winsock2.h. If you're looking for a cross platform sockets library I'd start with BSD sockets, probably in netBSD these days. It's where Microsoft started when they needed to 'source' a socket implementation for Win95 or so the rumour goes. ;)

          Nothing is exactly what it seems but everything with seems can be unpicked.

          B Offline
          B Offline
          Budric B
          wrote on last edited by
          #4

          No, in fact you need to include winsock2.h before windows.h because windows.h includes old winsock.h which interferes with the new one. Also winsock2.h may include windows.h anyway on line: #ifndef _INC_WINDOWS #include #endif I will check out the BSD sockets thing...thanks.

          M 1 Reply Last reply
          0
          • B Budric B

            No, in fact you need to include winsock2.h before windows.h because windows.h includes old winsock.h which interferes with the new one. Also winsock2.h may include windows.h anyway on line: #ifndef _INC_WINDOWS #include #endif I will check out the BSD sockets thing...thanks.

            M Offline
            M Offline
            Matthew Faithfull
            wrote on last edited by
            #5

            You're right, I'd forgotten about that particular peculiarity. One of my first tasks in paid software development was to change a project from winsock to winsock2. Amazing how quickly I forget things :laugh:

            Nothing is exactly what it seems but everything with seems can be unpicked.

            B 1 Reply Last reply
            0
            • M Matthew Faithfull

              You're right, I'd forgotten about that particular peculiarity. One of my first tasks in paid software development was to change a project from winsock to winsock2. Amazing how quickly I forget things :laugh:

              Nothing is exactly what it seems but everything with seems can be unpicked.

              B Offline
              B Offline
              Budric B
              wrote on last edited by
              #6

              I spent way too much time on this problem, that's why I know ;)

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups