I'm designing a simple Battleship game using SFML. The player's grid is assigned to a 2D array int playerGridd[10][10] and vice versa. I tried to use SFML networking to send playerGridd through TCP, the sending part has no issue, but the receiving does.
socket.receive(playerGridd, sizeof(playerGridd), enemyGridd) does not work
sf::TcpListener listener;
if (listener.listen(port) != sf::Socket::Done) return;
std::cout << "Server is listening to port: " << port << ", waiting for
connections..." << std::endl;
sf::TcpSocket socket;
if (listener.accept(socket) != sf::Socket::Done) return;
std::cout << "Client connected: " << socket.getRemoteAddress() <<
std::endl;
int playerGridd[gridSize][gridSize] = { 0 };
int enemyGridd[gridSize][gridSize] = { 0 };
while (state = play){
sf::Event event;
if (socket.send(playerGridd, sizeof(playerGridd) !=
sf::Socket::Done)) {
cout << "Fail to send player's grid" << endl;
}
if (socket.receive(playerGridd, sizeof(playerGridd), enemyGridd) !=
sf::Socket::Done) {
cout << "Fail to receive enemy's grid" << endl;
}
1>c:\sfml\battleship\server.cpp(144): error C2664: 'sf::Socket::Status sf::TcpSocket::receive(sf::Packet &)': cannot convert argument 3 from 'int [10][10]' to 'size_t &'