CSDN博客

img aloking

Winsock基本的api

发表于2004/7/14 12:00:00  1533人阅读

1. WSAStartup()

2. socket(int af,int type,int proctocol)

3. int bind(SOCKET s,strut sockaddr_in* name,int namelen);

struct sockaddr_in{

  short                sin_family;

  unsigned short  sin_port;

  struct in_addr   sin_addr;

  char                  sin_zero[8];

}

 

struct   in_addr{

    union {

         struct {

                  unsigned char s_b1,s_b2,s_b3,s_b4,

                  } s_un_b;

        struct {

                  unsigned short s_w1,s_w2;

                  } s_un_w;

         unsigned long s_addr;

}S_um;

}

 

int listen(SOCKET s,struct sockaddr_in *addr,int* addrlen);

int connect(SOCKET s,struct sockaddr_in* name,int namelen);

int send (SOCKET s,char* buf,int len,int flags);

int recv (SOCKET s, char* buf,int len,int flags);

已数据报文方式通信的socket 不用建立连接,可以跳过connect直接用

int recvfrom (SOCKET S,char* buf, int len, int flags,struct sockaddr_infrom ,in* fromlen);

int sendto(SOCKET s,char* buf,int len,int flags,struct sockaddr_into,int* tolen);

closesocket(SOCKET s);

本来还想画个图,不知道怎么画了

0 0

相关博文

我的热门文章

img
取 消
img