socket programming using wsa

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gnanapoongothai
    New Member
    • Jun 2007
    • 62

    socket programming using wsa

    hi,
    i am a beginner in socket programming in vc++. There is error poping up when the addr of the socket is compling,

    .\simple_socket sever.c(41): error: identifier "sockaddr_i n" is undefined
    sockaddr_in service;
    ^

    .\simple_socket sever.c(41): error: expected a ";"
    sockaddr_in service;
    ^

    .\simple_socket sever.c(43): error: identifier "service" is undefined
    service.sin_fam ily = AF_INET;
    ^

    Whats wrong here, have to include any lib files,and hoe to do it. plz help.and thanks in advance.
  • sicarie
    Recognized Expert Specialist
    • Nov 2006
    • 4677

    #2
    What is going on
    [code=error]
    .\simple_socket sever.c(41): error: identifier "sockaddr_i n" is undefined
    sockaddr_in service;
    ^ // here?
    [/code]
    You have this socaddr_in, is that the name of the object? What is service? Is it a method, or is it part of the name of the object? Right now there is a space in between sockaddr_in and service, so it's reading those as two separate things. Are you delcaring a new sockaddr_in?

    Comment

    • eagerlearner
      New Member
      • Jul 2007
      • 29

      #3
      Have you include the header file of ?
      #include <winsock2.h>

      Make sure you link your compiler with the library file called ws2_32.lib as well

      Comment

      • gnanapoongothai
        New Member
        • Jun 2007
        • 62

        #4
        How to link that lib files. working area is different and the lib files is in diferent area. So fatal error occurs while opening the lib files what to do?
        Awating ur reply.

        Comment

        • weaknessforcats
          Recognized Expert Expert
          • Mar 2007
          • 9214

          #5
          You have to do two things: 1) add the lib to your build and 2) enter the path to the lib.

          You add the lib to the build by going to project Properties/Configuration Properies/Linker/Input/Additional dependencies and enter the name of your library.

          Then, go to Tools/Options/Projects and Solutions/VC++ Directories. On the right pane is a drop-down menu. Select Library Files and enter your path there.

          Comment

          • gnanapoongothai
            New Member
            • Jun 2007
            • 62

            #6
            Got it done working fine.thanks

            Comment

            Working...