sendto

Passing a structure through Sockets in C

痞子三分冷 提交于 2019-11-26 00:36:31
问题 I am trying to pass whole structure from client to server or vice-versa. Let us assume my structure as follows struct temp { int a; char b; } I am using sendto and sending the address of the structure variable and receiving it on the other side using the recvfrom function. But I am not able to get the original data sent on the receiving end. In sendto function I am saving the received data into variable of type struct temp. n = sendto(sock, &pkt, sizeof(struct temp), 0, &server, length); n =