Udp CSocket

Udp

//server
CSocket t;
       t.Create(2000,SOCK_DGRAM,"127.0.0.1");
       t.Bind(2000,"127.0.0.1");
       char buf[1024]="hi1";
    t.SendTo(buf,strlen(buf),2000,"127.0.0.1",0);
//client
       CString add="127.0.0.1";
       UINT port=2000;
       ::AfxMessageBox(buf);
       int len=t.ReceiveFrom(buf,1023,add,port,0);
       buf[len+1]='\0';
       ::AfxMessageBox(buf);

你可能感兴趣的:(职场,UDP,休闲,CSocket)