TCP Client

Posts 1–7 of 7 · Page 1 of 1
TCP Client
whenever i try to compile my program i get "TcpClient undeclared". How do i fix this?
dev c++ portable
empty project
you must include ws2_32.lib. Google how to do it in dev c++ cuz i am not familiar with it.
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.
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
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;
}
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.
Posts 1–7 of 7 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us