Hi, I have an assignment to do (groan) which requires me to write the client side of a network, in the first part I have to write 3 functions, one which sets up a socket and connects to the server, one which sends a packet and one which receives a packet.
I've done the first function and it connects fine, no problems there. Now i'm trying to implement the send function, I've done as much as i can (up to the point where i feel i understand it but it still won't work!), here is my code:
Packet is a struct which holds a char array (called data) and another struct called Header which holds various bits of info about the packet.
Code:
// Send a packet to the socket
// Returns number of bytes written.
int socket_send_packet(int sock, PACKET *pkt, int reliable)
{
int bytes;
printf("Message sent: %s \n", pkt->data);
bytes = send(sock, pkt, sizeof(pkt), 0);
if(bytes < 0){
printf("Error: send\n");
exit(1);
}
printf("Number of bytes sent: %i\n", bytes);
return bytes;
}
The char[] in the packet is correct (as shown by the first printf), the number of bytes sent is correct as well. The send command doesn't produce an error, but nothing is received the other end
Anyone know what's going on?