Whitespace cleanups (yes, I do care about that)
This commit is contained in:
parent
aaaae93afc
commit
467515943d
1 changed files with 20 additions and 19 deletions
|
@ -100,35 +100,36 @@ uint64_t countRouters() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int createSocket() {
|
int createSocket() {
|
||||||
int create_socket;
|
int create_socket;
|
||||||
if((create_socket = socket(AF_LOCAL, SOCK_STREAM, 0)) < 0) {
|
if((create_socket = socket(AF_LOCAL, SOCK_STREAM, 0)) < 0) {
|
||||||
perror("socket");
|
perror("socket");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
unlink(SOCKET);
|
unlink(SOCKET);
|
||||||
|
|
||||||
struct sockaddr_un address;
|
struct sockaddr_un address;
|
||||||
socklen_t addrlen;
|
socklen_t addrlen;
|
||||||
address.sun_family = AF_UNIX;
|
address.sun_family = AF_UNIX;
|
||||||
strcpy(address.sun_path, SOCKET);
|
strcpy(address.sun_path, SOCKET);
|
||||||
addrlen = sizeof(address);
|
addrlen = sizeof(address);
|
||||||
|
|
||||||
if(bind(create_socket, (struct sockaddr *)&address, addrlen) != 0) {
|
if(bind(create_socket, (struct sockaddr *)&address, addrlen) != 0) {
|
||||||
perror("bind");
|
perror("bind");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
listen(create_socket, 5);
|
|
||||||
chmod(SOCKET, 0666);
|
|
||||||
|
|
||||||
return create_socket;
|
listen(create_socket, 5);
|
||||||
|
chmod(SOCKET, 0666);
|
||||||
|
|
||||||
|
return create_socket;
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleClient(int socket) {
|
void handleClient(int socket) {
|
||||||
struct sockaddr_un address;
|
struct sockaddr_un address;
|
||||||
socklen_t addrlen;
|
socklen_t addrlen;
|
||||||
int client = accept(socket, (struct sockaddr *)&address, &addrlen);
|
int client = accept(socket, (struct sockaddr *)&address, &addrlen);
|
||||||
if(client >= 0) {
|
if (client >= 0) {
|
||||||
std::stringstream ss("");
|
std::stringstream ss("");
|
||||||
ss << countRouters() << "\n";
|
ss << countRouters() << "\n";
|
||||||
write(client, ss.str().c_str(), ss.str().size());
|
write(client, ss.str().c_str(), ss.str().size());
|
||||||
|
|
Loading…
Reference in a new issue