c++ socket connection problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • pnigl

    c++ socket connection problem

    Hello, i tried to set up a socket connection with the following code:

    #include <afxwin.h>
    #include <afxsock.h>


    int main()//int argc, char* argv[]
    {
    CAsyncSocket socket;
    socket.Create() ;
    socket.Connect( "login.itd.umic h.edu", 13);

    // you might actually need to use OnReceive() here,
    // I'm not sure.
    char* Buffer = new char[256];
    socket.Receieve (Buffer, 255);
    AfxMessageBox(B uffer);

    return 0:
    }

    But there are the following Errormsg...


    winnt.h(1092) : error C2146: syntax error : missing ';' before
    identifier 'KSPIN_LOCK'

    winnt.h(1092) : fatal error C1004: unexpected end of file found
    Error executing cl.exe.


    ....and I have no clue how to fix it. If theres anyone who can help me
    please do so :-)
    Perhaps with some Documentation.. .

    Very much thx
  • Ron Natalie

    #2
    Re: c++ socket connection problem


    "pnigl" <pnigl@gmx.de > wrote in message news:f42d658d.0 401191145.633d5 f60@posting.goo gle.com...[color=blue]
    > Hello, i tried to set up a socket connection with the following code:
    >
    > #include <afxwin.h>
    > #include <afxsock.h>
    >[/color]
    These two lines are highly suspect. I suspect you're omitting a required include
    file.

    However, CAsyncSocket and all the MFC idiocy is off-topic here. Try
    micrsoft.public .vc.mfc

    Comment

    • user@domain.invalid

      #3
      Re: c++ socket connection problem

      pnigl wrote:[color=blue]
      > Hello, i tried to set up a socket connection with the following code:
      >
      > #include <afxwin.h>
      > #include <afxsock.h>
      >
      >
      > int main()//int argc, char* argv[]
      > {
      > CAsyncSocket socket;
      > socket.Create() ;
      > socket.Connect( "login.itd.umic h.edu", 13);
      >
      > // you might actually need to use OnReceive() here,
      > // I'm not sure.
      > char* Buffer = new char[256];
      > socket.Receieve (Buffer, 255);
      > AfxMessageBox(B uffer);
      >
      > return 0:[/color]
      I think it's this colon right here!!
      [color=blue]
      > }
      >
      > But there are the following Errormsg...
      >
      >
      > winnt.h(1092) : error C2146: syntax error : missing ';' before
      > identifier 'KSPIN_LOCK'
      >
      > winnt.h(1092) : fatal error C1004: unexpected end of file found
      > Error executing cl.exe.
      >
      >
      > ...and I have no clue how to fix it. If theres anyone who can help me
      > please do so :-)
      > Perhaps with some Documentation.. .
      >
      > Very much thx[/color]

      Comment

      • red floyd

        #4
        Re: c++ socket connection problem

        user@domain.inv alid wrote:[color=blue]
        > pnigl wrote:
        >[color=green]
        >> Hello, i tried to set up a socket connection with the following code:
        >>
        >> #include <afxwin.h>
        >> #include <afxsock.h>
        >>
        >>
        >> int main()//int argc, char* argv[]
        >> {
        >> CAsyncSocket socket;
        >> socket.Create() ;
        >> socket.Connect( "login.itd.umic h.edu", 13);
        >>
        >> // you might actually need to use OnReceive() here,
        >> // I'm not sure.
        >> char* Buffer = new char[256];
        >> socket.Receieve (Buffer, 255);
        >> AfxMessageBox(B uffer);
        >>
        >> return 0:[/color]
        >
        > I think it's this colon right here!!
        >[color=green]
        >> }
        >>
        >> But there are the following Errormsg...
        >>
        >> winnt.h(1092) : error C2146: syntax error : missing ';' before
        >> identifier 'KSPIN_LOCK'
        >>
        >> winnt.h(1092) : fatal error C1004: unexpected end of file found
        >> Error executing cl.exe.
        >>[/color][/color]

        As mentioned, this is way OT for c.l.c++, but You have a serious problem.
        KSPIN_LOCK comes from the DDK, not from the SDK. Do you have the DDK installed?
        Check your environment for INCLUDE_PATH (or whatever the hell VC uses).

        Comment

        • Chris Mantoulidis

          #5
          Re: c++ socket connection problem

          pnigl@gmx.de (pnigl) wrote in message news:<f42d658d. 0401191145.633d 5f60@posting.go ogle.com>...[color=blue]
          > Hello, i tried to set up a socket connection with the following code:
          >
          > #include <afxwin.h>
          > #include <afxsock.h>
          >
          >
          > int main()//int argc, char* argv[]
          > {
          > CAsyncSocket socket;
          > socket.Create() ;
          > socket.Connect( "login.itd.umic h.edu", 13);
          >
          > // you might actually need to use OnReceive() here,
          > // I'm not sure.
          > char* Buffer = new char[256];
          > socket.Receieve (Buffer, 255);
          > AfxMessageBox(B uffer);
          >
          > return 0:
          > }
          >
          > But there are the following Errormsg...
          >
          >
          > winnt.h(1092) : error C2146: syntax error : missing ';' before
          > identifier 'KSPIN_LOCK'
          >
          > winnt.h(1092) : fatal error C1004: unexpected end of file found
          > Error executing cl.exe.
          >
          >
          > ...and I have no clue how to fix it. If theres anyone who can help me
          > please do so :-)
          > Perhaps with some Documentation.. .
          >
          > Very much thx[/color]

          I never liked WinSocks... I can't help you with them. If you have a
          prob with sockets for linux, catch me somewhere and ask :)

          BTW: go to the M$ mfc newsgroup instead...

          Comment

          • Chris Mantoulidis

            #6
            Re: c++ socket connection problem

            pnigl@gmx.de (pnigl) wrote in message news:<f42d658d. 0401191145.633d 5f60@posting.go ogle.com>...[color=blue]
            > Hello, i tried to set up a socket connection with the following code:
            >
            > #include <afxwin.h>
            > #include <afxsock.h>
            >
            >
            > int main()//int argc, char* argv[]
            > {
            > CAsyncSocket socket;
            > socket.Create() ;
            > socket.Connect( "login.itd.umic h.edu", 13);
            >
            > // you might actually need to use OnReceive() here,
            > // I'm not sure.
            > char* Buffer = new char[256];
            > socket.Receieve (Buffer, 255);
            > AfxMessageBox(B uffer);
            >
            > return 0:
            > }
            >
            > But there are the following Errormsg...
            >
            >
            > winnt.h(1092) : error C2146: syntax error : missing ';' before
            > identifier 'KSPIN_LOCK'
            >
            > winnt.h(1092) : fatal error C1004: unexpected end of file found
            > Error executing cl.exe.
            >
            >
            > ...and I have no clue how to fix it. If theres anyone who can help me
            > please do so :-)
            > Perhaps with some Documentation.. .
            >
            > Very much thx[/color]

            Well, maybe 1 thing to point out

            just leave an empty line at the end of the source file to get rid of the 2nd error.

            oh, about the first, you got "return 0:" which should be "return 0;"

            Comment

            Working...