????д????棺С???????????????????????????????????????á????п??????С??????????????????????????????????????????????????????????????????????????????м???
????????????Щ???????????????????????????
?????л???socket???????????????????????????????????????????????????
??????????????????????е????????ú????????????????????????????

 

<span style="font-size:18px;"><span style="font-family:SimSun;font-size:18px;">#include<sys/socket.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<linux/un.h>
#include<unistd.h>
int main()
{
char buf[256];
int fd = socket(AF_UNIX??SOCK_DGRAM??0);
if( fd == -1 )
{
printf("socket error:%m ");
exit(-1);
}else
{
printf("socket complete ");
}
struct sockaddr_un addr = {0};
addr.sun_family = AF_UNIX;
memcpy(addr.sun_path??"my.sock"??strlen("my.sock"));
int r = bind( fd??reinterpret_cast<struct sockaddr*>(&addr)??sizeof(addr) );
if( r == -1 )
{
printf("bind error:%m ");
exit(-1);
}else
{
printf("bind complete ");
}
while(1)
{
bzero(buf??sizeof(buf));
r = read(fd??buf??sizeof(buf));
buf[r] = '