C Socket 发送/接收数据结构

typedef struct {
   char s[20];
   int i;
   float f;
  } S;
  S *s=(S*)malloc(sizeof(S));
  Sendto(sockfd, s, sizeof(S), 0, pservaddr, servlen);
 

  Recvfrom(sockfd, s, sizeof(S), 0, pcliaddr, &len);
  printf("receive:%lf,%d,%s\n",s->f,s->i,s->s);
 
 

原文地址:https://www.cnblogs.com/yangyh/p/1763996.html