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
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