DDVSocket edits
This commit is contained in:
parent
72f150aaf6
commit
708829b5a9
2 changed files with 9 additions and 3 deletions
|
@ -48,7 +48,7 @@ int main(int argc, char ** argv){
|
||||||
int status;
|
int status;
|
||||||
while (server_socket > 0){
|
while (server_socket > 0){
|
||||||
waitpid((pid_t)-1, &status, WNOHANG);
|
waitpid((pid_t)-1, &status, WNOHANG);
|
||||||
CONN_fd = DDV_Accept(server_socket);
|
CONN_fd = DDV_Accept(server_socket, true);
|
||||||
if (CONN_fd > 0){
|
if (CONN_fd > 0){
|
||||||
pid_t myid = fork();
|
pid_t myid = fork();
|
||||||
if (myid == 0){
|
if (myid == 0){
|
||||||
|
|
|
@ -55,8 +55,14 @@ int DDV_Listen(int port){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int DDV_Accept(int sock){
|
int DDV_Accept(int sock, bool nonblock = false){
|
||||||
return accept(sock, 0, 0);
|
int r = accept(sock, 0, 0);
|
||||||
|
if ((r > 0) && nonblock){
|
||||||
|
int flags = fcntl(r, F_GETFL, 0);
|
||||||
|
flags |= O_NONBLOCK;
|
||||||
|
fcntl(r, F_SETFL, flags);
|
||||||
|
}
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DDV_write(void * buffer, int todo, int sock){
|
bool DDV_write(void * buffer, int todo, int sock){
|
||||||
|
|
Loading…
Add table
Reference in a new issue