Something
public text v1 · immutable#include <unistd.h>
#include <fcntl.h>
#include <sys/socket.h>
#include "socket.h"
Socket::Socket(){
this->fd=-1;
}
int Socket::Listen(int backlog){
return listen(this->fd,backlog);
}
int Socket::relisten(int oldfd){
this->fd=oldfd;
return 0;
}
int Socket::Accept(Socket&newone){
int clen=sizeof(this->peer);
newone.fd=accept(this->fd,(sockaddr*)&(newone.peer),(socklen_t*)&clen);
this->opentime=time(NULL);
fcntl(this->fd, F_SETFL, O_NONBLOCK);
return newone.fd;
}