PDA

Click to See Complete Forum and Search --> : [RESOLVED] Getting the server to send a message back to the client


steve_rm
Oct 18th, 2007, 05:27 AM
Hello,

I am created a client server application using the poco libraries. And using UDP.

However, I would like to do something with the data and then send it back to the client.

However, I don't know how to send back to the client, once the server has received the data from the client.

Here is my code for the client, as simple as I can get it.

Poco::Net::SocketAddress addr("PiyaLim", 6000);
Poco::Net::DatagramSocket sock;

sock.sendTo("Manchester United",17,addr);


Code for the server:

char buffer[256] = {0};
sock.receiveFrom(buffer,sizeof(buffer), addr);
std::string message = buffer;
int strLength = 0;
strLength = message.length();
message = message.substr(0,strLength);

std::cout << "*********************** START ***********************************************" << std::endl;
std::cout << "The message is: " << message << " The length of the string is: " << strLength << std::endl;
std::cout << "Address: " << addr.host().toString() << std::endl;
std::cout << "Port Number: " << addr.port() << std::endl;
std::cout << "*********************** END *************************************************" << std::endl;


Many thanks for any help with this.

Steve

drivenbywhat
Oct 18th, 2007, 09:28 AM
Well I don't know anything about poco or what language you seem to be using (c?). However, it looks like you know how to send data from the client to the server. What's stopping you from doing the same from the server to the client? It should be the send thing. Once you manipulate the data, store it in a variable and send it back to the client and have it ready to receive.