25 lines
464 B
C++
25 lines
464 B
C++
|
#include <stdio.h>
|
||
|
#include <string.h>
|
||
|
#include <sys/socket.h>
|
||
|
#include <sys/un.h>
|
||
|
|
||
|
int main()
|
||
|
{
|
||
|
int sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||
|
if (sockfd < 0)
|
||
|
{
|
||
|
perror("socket");
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
struct sockaddr_un un;
|
||
|
un.sun_family = AF_UNIX;
|
||
|
strncpy(un.sun_path, "/tmp/local.sock", sizeof(un.sun_path));
|
||
|
|
||
|
if (bind(sockfd, (struct sockaddr*)&un, sizeof(un)) < 0)
|
||
|
{
|
||
|
perror("bind");
|
||
|
return 1;
|
||
|
}
|
||
|
}
|