UNP_1_Chapter 3__基本socket

进程->内核,传递socket地址的函数:bind、connect、sendto
进程<-内核,传递socket地址的函数:accept、recvfrom、getsockname、getpeername

//使用前置0,好习惯
bzero(x,sizeof(struct sockaddr_in));
struct sockaddr_in
{
  uint8_t        sin_len;    //不一定有
  sa_family_t    sin_family; //不一定有

  in_port_t      sin_port;
  struct in_addr sin_addr;
  unsigned char  sin_zero[8];
};


typedef uint32_t in_addr_t;
struct in_addr
{
  in_addr_t s_addr;
};

//
struct sockaddr
{
  uint8_t  sa_len;
  sa_family_t   sa_family;
  char          sa_data[14];
};

你可能感兴趣的:(C++,c,socket,C#)