1
Réseau / Re : Problème à recevoir un pointeur de uchar par TCP
« le: Février 12, 2015, 12:33:53 am »
Topic à fermer j'ai résolu mon problèmes avec les packets.
Mon code :
Client :
Serveur :
Mon code :
Client :
sf::Packet packet;
for (int i = 0; i < 921600; i++)
{
packet << frame.data[i];
}
// Send data
if (socket.send(packet) != sf::Socket::Done)
{
cout << "ERROR : Fail to send" << endl;
}
else
{
cout << "Sended : " << imgSize << endl;
}
for (int i = 0; i < 921600; i++)
{
packet << frame.data[i];
}
// Send data
if (socket.send(packet) != sf::Socket::Done)
{
cout << "ERROR : Fail to send" << endl;
}
else
{
cout << "Sended : " << imgSize << endl;
}
Serveur :
Mat frame = Mat::zeros(480, 640, CV_8UC3);
const int size = 921600;
sf::Packet packet;
if (client.receive(packet) != sf::Socket::Done)
{
cout << "ERROR : Can't receive data" << endl;
}
else
{
// Extract packet into img.data
for (int i = 0; i < 921600; i++)
{
packet >> frame.data[i];
}
// Save as .jpg
imwrite("received.jpg", frame);
}
const int size = 921600;
sf::Packet packet;
if (client.receive(packet) != sf::Socket::Done)
{
cout << "ERROR : Can't receive data" << endl;
}
else
{
// Extract packet into img.data
for (int i = 0; i < 921600; i++)
{
packet >> frame.data[i];
}
// Save as .jpg
imwrite("received.jpg", frame);
}