Thread: TCP Client

Results 1 to 7 of 7
  1. #1
    kibbles18's Avatar
    Join Date
    Oct 2008
    Gender
    male
    Location
    US
    Posts
    860
    Reputation
    5
    Thanks
    127

    TCP Client

    whenever i try to compile my program i get "TcpClient undeclared". How do i fix this?
    dev c++ portable
    empty project

  2. #2
    258456's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    ghjghj
    Posts
    1,222
    Reputation
    18
    Thanks
    300
    My Mood
    Relaxed
    you must include ws2_32.lib. Google how to do it in dev c++ cuz i am not familiar with it.

  3. The Following User Says Thank You to 258456 For This Useful Post:

    KissU (09-27-2011)

  4. #3
    Hassan's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    System.Threading.Tasks
    Posts
    4,764
    Reputation
    495
    Thanks
    2,133
    My Mood
    Dead
    Just yesterday I made a chat client for my cousin's project.

    [highlight=c++]#pragma comment(lib, "ws2_32.lib")
    #include <winsock2.h>[/highlight]

    First line clears up some unresolved symbols.
    As far as I know, #pragma comment is specifically supported by VC++. DevC++ uses MingW. To include library in DevC++, goto Project Options and then on Parameters Tab.

  5. #4
    Nico's Avatar
    Join Date
    Jan 2011
    Gender
    male
    Location
    Germany :D
    Posts
    15,918
    Reputation
    1121
    Thanks
    8,617
    Quote Originally Posted by Hassan View Post
    Just yesterday I made a chat client for my cousin's project.

    [highlight=c++]#pragma comment(lib, "ws2_32.lib")
    #include <winsock2.h>[/highlight]

    First line clears up some unresolved symbols.
    As far as I know, #pragma comment is specifically supported by VC++. DevC++ uses MingW. To include library in DevC++, goto Project Options and then on Parameters Tab.
    Not quite sure but I think I used #pragma comment in DevC++ before

  6. #5
    kibbles18's Avatar
    Join Date
    Oct 2008
    Gender
    male
    Location
    US
    Posts
    860
    Reputation
    5
    Thanks
    127
    The preprocessors are likley the same for dev and vs

    I tried including common sockrt headers to no succss. I shouldnt have to though, tcpclient is supposedly in the standard library.

    EDIT: heres a snippet of the code[
    Code:
    /* INCLUDES */
    #pragma comment(lib, "ws2_32.lib")
    #include <winsock2.h> 
    #include <windows.h>
    #include <iostream>
    
    /* NAMESPACES */
    using namespace std;
    
    /* FUNCTION PROTOTYPES */
    void print(const char [32]);
    
    int main()
    {
        char buf[50];
        char username[16];
        char password[32];
        print("welcome to mc_bot 1.0!");
        printf("username: ");
        scanf("%s", username);
        printf("password: ");
        scanf("%s", password);
        TcpClient client = new TcpClient("127.0.0.1", 26656);
        Sleep(2000);
        return 0;
    }
    Last edited by kibbles18; 09-24-2011 at 10:49 AM.

  7. #6
    ISmokeWeedAmICoolNow's Avatar
    Join Date
    Aug 2011
    Gender
    male
    Posts
    54
    Reputation
    10
    Thanks
    19
    My Mood
    Bitchy
    Quote Originally Posted by kibbles18 View Post
    The preprocessors are likley the same for dev and vs

    I tried including common sockrt headers to no succss. I shouldnt have to though, tcpclient is supposedly in the standard library.

    EDIT: heres a snippet of the code[
    Code:
    /* INCLUDES */
    #pragma comment(lib, "ws2_32.lib")
    #include <winsock2.h> 
    #include <windows.h>
    #include <iostream>
    
    /* NAMESPACES */
    using namespace std;
    
    /* FUNCTION PROTOTYPES */
    void print(const char [32]);
    
    int main()
    {
        char buf[50];
        char username[16];
        char password[32];
        print("welcome to mc_bot 1.0!");
        printf("username: ");
        scanf("%s", username);
        printf("password: ");
        scanf("%s", password);
        TcpClient client = new TcpClient("127.0.0.1", 26656);
        Sleep(2000);
        return 0;
    }
    it's not in the standard library. if you actually looked it up you would see it's obviously a managed class.

  8. #7
    kibbles18's Avatar
    Join Date
    Oct 2008
    Gender
    male
    Location
    US
    Posts
    860
    Reputation
    5
    Thanks
    127
    thanks for the bump

Similar Threads

  1. [Request] Can this be done (TCP Client/Server)? [solved]
    By miksa555 in forum Visual Basic Programming
    Replies: 23
    Last Post: 08-23-2011, 02:12 PM
  2. [Open Source]Docket[TCP Socket DLL] (Client Only)
    By Deto in forum Visual Basic Programming
    Replies: 17
    Last Post: 02-05-2011, 09:02 AM
  3. DOWNLOAD WoW.exe HERE! (Full Client For MPGH Server)
    By RebornAce in forum General Gaming
    Replies: 25
    Last Post: 05-14-2006, 02:54 AM
  4. where can i get older client?
    By DrKaOs in forum WarRock - International Hacks
    Replies: 5
    Last Post: 02-05-2006, 10:04 AM