visual studio - C++ sending vector object between client and server -
i'm new c++ , have never worked vectors or server/clients before. have client , server can send char messages 1 other. 1 problem can send individual words across. if sees space put next thing on new line. need able send objects client. without weird spacing issues
i have vector contains objects example have 1 called:
vector<employees> staff;
has print method:
void printvector(const vector<employees>&);
my question how can send vector or use printvector method show/print/cout on both server , client (through sending somehow).
here segment server.cpp file
if (sconnect = accept(slisten, (sockaddr*)&addr, &addrlen)) { cout << "connection received!" << endl << endl << "sending file" << endl << endl; (;; sleep(10)) { char* message = new char[256]; zeromemory(message, 256); cin >> message; getchar(); send(sconnect, message, 256, null); } } return 0;
here segment client.cpp file
if (confirm == "y" ) { connect(sconnect, (sockaddr*)&addr, sizeof(addr)); cout << "connected!" << endl << "" << endl; char* message = new char[256]; zeromemory(message, sizeof(message)); (;; sleep(50)) { if (recv(sconnect, message, 256, null)) { cout << message; zeromemory(message, 256); cout << endl; } } } else { cout << "you did not yes or error has occured" << endl << "closing connection" << endl; exit(0); }
all appreciated :)
leigh, have skype? if add me, , i'll out. have feeling watched same youtube tutorials did on server/client, , they're awful. don't understand how works.
add me on skype : jmoneyswaghoes if want on understanding how servers/clients work , how program working how you'd like.
Comments
Post a Comment