Lnk 1104 Error

This is a discussion on Lnk 1104 Error within the C++ Programming forums, part of the General Programming Boards category; hey guys , I'm kinda new to this , so forgive me if i'm wrong. I'm working on some multi ...

  1. #1
    Hail Linus Torvalds
    Join Date
    Sep 2004
    Posts
    14

    Unhappy Lnk 1104 Error

    hey guys ,
    I'm kinda new to this , so forgive me if i'm wrong. I'm working on some multi client-server code. I'm pretty new to MS Visual Studio 2003. I need to know the procedure do get code to run on MS Visual studio 2003. I keep getting that error LNK 1104 saying a file is missing or something. Can you guys help me out please. The code is taken from Distributed OS by Tanenbaum Listing 7.17 & 7.18
    Thank you
    Bharat

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,821
    How about posting some useful information, like the code you tried to compile and the actual error messages.

    > The code is taken from Distributed OS by Tanenbaum Listing 7.17 & 7.18
    Not everyone has that book
    The book may be wrong
    You may have copied it wrong

    > I need to know the procedure do get code to run on MS Visual studio 2003
    Probably calling a whole bunch of unix-centric calls like fork() then, seeing as it is an OS book you're looking at.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Hail Linus Torvalds
    Join Date
    Sep 2004
    Posts
    14
    It would take me forever to type that code out. And I don't even have it online to post it.Just want to know the General procedure to run a client-server code in MS.NET.No it dosen't have fork() system calls as it's purely windows based. Hope this helps

  4. #4

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,821
    > It would take me forever to type that code out
    Gee, how the hell did you compile it then?

    Lemme guess
    ctrl-a selects all text
    ctrl-c copies it
    ctrl-v pastes it

    Surely it can't be that difficult...
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  6. #6
    Hail Linus Torvalds
    Join Date
    Sep 2004
    Posts
    14
    ok i don't have a copy of it right now ,'cause i never saved it to disk.But i'll get one soon and let you take a look at it

  7. #7
    Hail Linus Torvalds
    Join Date
    Sep 2004
    Posts
    14

    ok here's the code

    Code:
    //code for the server
    //***************************************************************
    // From the book "Win32 System Services: The Heart of Windows 95
    // and Windows NT"
    // by Marshall Brain
    // Published by Prentice Hall
    //
    // Copyright 1995, by Prentice Hall.
    //
    // This code implements a TCP server.
    //***************************************************************
    
    // msipserv.cpp
    
    #include <windows.h>
    #include <iostream.h>
    #include <winsock.h>
    #include <process.h>
    
    #define NO_FLAGS_SET 0
    
    #define PORT (u_short) 44965
    #define MAXBUFLEN 256
    
    VOID talkToClient(VOID *cs)
    {
      char buffer[MAXBUFLEN];
      int status;
      int numsnt;
      int numrcv;
      SOCKET clientSocket=(SOCKET)cs;
    
      while(1)
      {
        numrcv=recv(clientSocket, buffer, 
          MAXBUFLEN, NO_FLAGS_SET);
        if ((numrcv == 0) || (numrcv == SOCKET_ERROR))
        {
          cout << "Connection terminated" << endl;
          break;
        }
    
        _strupr(buffer);
    
        numsnt=send(clientSocket, buffer, 
          strlen(buffer) + 1, NO_FLAGS_SET);
        if (numsnt != (int)strlen(buffer) + 1)
        {
          cout << "Connection terminated." << endl;
          break;
        }
    
      } /* while */
    
      /* terminate the connection with the client
         (disable sending/receiving) */
      status=shutdown(clientSocket, 2);
      if (status == SOCKET_ERROR)
        cerr << "ERROR: shutdown unsuccessful" << endl;
    
      /* close the socket */
      status=closesocket(clientSocket);
      if (status == SOCKET_ERROR)
        cerr << "ERROR: closesocket unsuccessful"
          << endl;
    }
    
    INT main(VOID)
    {
      WSADATA Data;
      SOCKADDR_IN serverSockAddr;
      SOCKADDR_IN clientSockAddr;
      SOCKET serverSocket;
      SOCKET clientSocket;
      int addrLen=sizeof(SOCKADDR_IN);
      int status;
      DWORD threadID;
    
      /* initialize the Windows Socket DLL */
      status=WSAStartup(MAKEWORD(1, 1), &Data);
      if (status != 0)
      {
        cerr << "ERROR: WSAStartup unsuccessful" 
          << endl;
        return(1);
      }
    
      /* zero the sockaddr_in structure */
      memset(&serverSockAddr, 0,
        sizeof(serverSockAddr));
      /* specify the port portion of the address */
      serverSockAddr.sin_port=htons(PORT);
      /* specify the address family as Internet */
      serverSockAddr.sin_family=AF_INET;
      /* specify that the address does not matter */
      serverSockAddr.sin_addr.s_addr=htonl(INADDR_ANY);
    
      /* create a socket */
      serverSocket=socket(AF_INET, SOCK_STREAM, 0);
      if (serverSocket == INVALID_SOCKET)
      {
        cerr << "ERROR: socket unsuccessful"
          << endl;
        status=WSACleanup();
        if (status == SOCKET_ERROR)
          cerr << "ERROR: WSACleanup unsuccessful" 
            << endl;
        return(1);
      }
    
      /* associate the socket with the address */
      status=bind(serverSocket, 
        (LPSOCKADDR) &serverSockAddr,
        sizeof(serverSockAddr));
      if (status == SOCKET_ERROR)
        cerr << "ERROR: bind unsuccessful" << endl;
    
      /* allow the socket to take connections */
      status=listen(serverSocket, 1);
      if (status == SOCKET_ERROR)
        cerr << "ERROR: listen unsuccessful" << endl;
    
      while(1)
      {
        /* accept the connection request when 
           one is received */
        clientSocket=accept(serverSocket,
          (LPSOCKADDR) &clientSockAddr,
          &addrLen);
        if (clientSocket == INVALID_SOCKET)
        {
          cerr << "ERROR: Unable to accept connection."
            << endl;
          return(1);
        }
    
        threadID=_beginthread(talkToClient,
          0, (VOID *)clientSocket);
        if (threadID == -1)
        {
          cerr << "ERROR: Unable to create thread"
            << endl;
          /* close the socket */
          status=closesocket(clientSocket);
          if (status == SOCKET_ERROR)
            cerr << "ERROR: closesocket unsuccessful" 
              << endl;
        }
    
      } /* while */
    
    }
    Code:
    //code for the client
    //***************************************************************
    // From the book "Win32 System Services: The Heart of Windows 95
    // and Windows NT"
    // by Marshall Brain
    // Published by Prentice Hall
    //
    // Copyright 1995, by Prentice Hall.
    //
    // This code implements a TCP client.
    //***************************************************************
    
    // msipclnt.cpp
    
    #include <windows.h>
    #include <iostream.h>
    #include <winsock.h>
    
    #define NO_FLAGS_SET 0
    
    #define PORT (u_short) 44965
    #define DEST_IP_ADDR "127.0.0.1"
    #define MAXBUFLEN 256
    
    INT main(VOID)
    {
      WSADATA Data;
      SOCKADDR_IN destSockAddr;
      SOCKET destSocket;
      unsigned long destAddr;
      int status;
      int numsnt;
      int numrcv;
      char sendText[MAXBUFLEN];
      char recvText[MAXBUFLEN];
    
      /* initialize the Windows Socket DLL */
      status=WSAStartup(MAKEWORD(1, 1), &Data);
      if (status != 0)
        cerr << "ERROR: WSAStartup unsuccessful"
          << endl;
    
      /* convert IP address into in_addr form*/
      destAddr=inet_addr(DEST_IP_ADDR);
      /* copy destAddr into sockaddr_in structure */
      memcpy(&destSockAddr.sin_addr, &destAddr,
        sizeof(destAddr));
      /* specify the port portion of the address */
      destSockAddr.sin_port=htons(PORT);
      /* specify the address family as Internet */
      destSockAddr.sin_family=AF_INET;
    
      /* create a socket */
      destSocket=socket(AF_INET, SOCK_STREAM, 0);
      if (destSocket == INVALID_SOCKET)
      {
        cerr << "ERROR: socket unsuccessful" << endl;
        status=WSACleanup();
        if (status == SOCKET_ERROR)
          cerr << "ERROR: WSACleanup unsuccessful" 
            << endl;
        return(1);
      }
    
      cout << "Trying to connect to IP Address: " 
        << DEST_IP_ADDR << endl;
    
      /* connect to the server */
      status=connect(destSocket, 
        (LPSOCKADDR) &destSockAddr,
        sizeof(destSockAddr));
      if (status == SOCKET_ERROR)
      {
        cerr << "ERROR: connect unsuccessful"
          << endl;
        status=closesocket(destSocket);
        if (status == SOCKET_ERROR)
          cerr << "ERROR: closesocket unsuccessful"
            << endl;
        status=WSACleanup();
        if (status == SOCKET_ERROR)
          cerr << "ERROR: WSACleanup unsuccessful" 
            << endl;
        return(1);
      }
    
      cout << "Connected..." << endl;
    
      while(1)
      {
        cout << "Type text to send: ";
        cin.getline(sendText, MAXBUFLEN);
    
        /* Send the message to the server */
        numsnt=send(destSocket, sendText, 
          strlen(sendText) + 1, NO_FLAGS_SET);
        if (numsnt != (int)strlen(sendText) + 1)
        {
          cout << "Connection terminated." << endl;
          status=closesocket(destSocket);
          if (status == SOCKET_ERROR)
            cerr << "ERROR: closesocket unsuccessful"
              << endl;
          status=WSACleanup();
          if (status == SOCKET_ERROR)
            cerr << "ERROR: WSACleanup unsuccessful"
              << endl;
          return(1);
        }
    
        /* Wait for a response from server */
        numrcv=recv(destSocket, recvText, 
          MAXBUFLEN, NO_FLAGS_SET);
        if ((numrcv == 0) || (numrcv == SOCKET_ERROR))
        {
          cout << "Connection terminated.";
          status=closesocket(destSocket);
          if (status == SOCKET_ERROR)
            cerr << "ERROR: closesocket unsuccessful"
              << endl;
          status=WSACleanup();
          if (status == SOCKET_ERROR)
            cerr << "ERROR: WSACleanup unsuccessful"
              << endl;
          return(1);
        }
    
        cout << "Received: " <<  recvText << endl;
    
     } /* while */
      
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 09:18 PM
  2. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 02:01 AM
  3. Quantum Random Bit Generator
    By shawnt in forum C++ Programming
    Replies: 62
    Last Post: 06-18-2008, 11:17 AM
  4. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  5. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 11:03 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21