Hello, I was wondering if it was possible to take a string variable or an integer variable and send it to another computer like client/server architecture and also read that data from that same computer. I am thinking that winsock will be ideal for doing this but if anyone knows anything else thats better please tell me. Also if winsock is good for this than can someone point me in the right direction for getting started with it using C++.

Thanks, any help is appreciated.

Just google for "beej".
It's a widely quoted tutorial.

ok, I have looked through all those tutorials and many other tutorials but it doesnt make sense to me because I am using codeblocks and I keep getting linker errors and all sorts of things. Could someone help me out. I want to be able to take a string variable or an integer variable and send it in a text file to another computer which will be the server. That beej guide isnt helping right now. maybe if someone can post the starting code or explain the linkers for code blocks that would be great. the compiler is GCC or something.

You could try posting your code AND error messages.

Do you expect your doctor to come up with accurate diagnoses when all you can manage to say is "it hurts" ?

lol, what I am saying is is that I dont no where to start. I mean the linkers it tells me to put in dont even work with the GNU GCC Compiler in codeblocks. Therefore I cant even write any code yet for the networking of the program.

I mean the linkers it tells me to put in dont even work with the GNU GCC Compiler in codeblocks.

Excuse me?

Consider this to be the flavour of the problem rather than an answer (I don't have code blocks on this machine).

In the project settings, there should be a tab to configure the linker. Here you can tell the linker the places where to find other libraries, and the names of those libraries. It may already have the "standard set" of libraries already listed.

What you need to add to that is the name of the winsock library, which IIRC is called ws2_32.lib

Dev-C++ for example calls it libws2_32.a, so feel free to search for likely looking names ending in .lib or .a.

If code blocks follows the standard library naming convention, then libws2_32.a will simply be called ws2_32 on the linker command line.

Thanks i'll give it a shot, and sorry to the messy grammar, I was typing the earlier post quick.

real time example for circular linked list

Ok, I got the linker working now and I was following the guide on beej but its not working. It gets errors while debugging. Here is my source code, I am not sure what I am doing wrong. But its not the linker this time, I got that to work. Its something in the new winsock code I put in.

#include <iostream>
#include <windows.h>
#include <winsock.h>
using namespace std;

{
    WSADATA wsaData;   // if this doesn't work
    //WSAData wsaData; // then try this instead

    if (WSAStartup(MAKEWORD(1, 1), &wsaData) != 0) {
        fprintf(stderr, "WSAStartup failed.\n");
        exit(1);
    }
int main()
{
    system ("TITLE Might and Power");
    cout << "\n";
	cout << "\n";
	cout << "\n";
	cout << "\n";
	cout << "\n";
	cout << "\n";
	cout << "\n";
	cout << "\n";
	cout << "\n";
    cout << "                              Sector 2 Entertainment";
    Sleep(3000);
	system("cls");
    cout << "\n";
	cout << "\n";
	cout << "\n";
	cout << "\n";
	cout << "\n";
	cout << "\n";
	cout << "\n";
	cout << "\n";
	cout << "\n";
    cout << "                                     Presents";
	Sleep(2000);
	system("cls");
	cout << "\n";
	cout << "\n";
	cout << "\n";
	cout << "\n";
	cout << "\n";
	cout << "\n";
	cout << "\n";
	cout << "\n";
	cout << "\n";
    cout << "                                 Might and Power";
	Sleep(3000);
	cout << "\n";
	cout << "\n                                 1) Create Character";
	cout << "\n                                 2) Load Character";
	cout << "\n                                 3) Exit Game";
	cout << "\n";
	cout << "\n                                 Enter an Option: ";
	int choice;
	cin >> choice;
	if (choice == 1)
    	CreateCharacter();
    if (choice == 2)
        LoadCharacter();
}

Well your wsa startup is a random bit of code not in any function, and mis-matched braces as well.

so does the wsa startup have to be in a function like connection or w.e and wat do I do with the braces. Srry if i sound like a noob I am just really lost with this winsock stuff.

How you order the code (all inline in main, lots of functions ) is entirely up to you.

But I'd go with

int main (  ) {
  // do wsa startup here
  // call function to do the entire network session
  // do wsa cleanup here
}

Ok, thanks I'll give it a shot.

Is that beej guide in C because some of the syntax seems like it is, maybe thats why I am getting errors when debugging aswell.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.