mirror of
https://github.com/Relintai/rcpp_framework.git
synced 2024-11-10 00:52:11 +01:00
Moved socket from trantor to core.
This commit is contained in:
parent
1fbf6a22c1
commit
0e6ad2d135
@ -12,10 +12,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "Socket.h"
|
||||
#include "socket.h"
|
||||
#include <assert.h>
|
||||
#include <sys/types.h>
|
||||
#include <trantor/utils/Logger.h>
|
||||
#ifdef _WIN32
|
||||
#include <ws2tcpip.h>
|
||||
#else
|
||||
@ -56,7 +55,7 @@ void Socket::bindAddress(const InetAddress &localaddr) {
|
||||
if (ret == 0)
|
||||
return;
|
||||
else {
|
||||
LOG_SYSERR << ", Bind address failed at " << localaddr.toIpPort();
|
||||
//LOG_SYSERR << ", Bind address failed at " << localaddr.toIpPort();
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
@ -64,7 +63,7 @@ void Socket::listen() {
|
||||
assert(sockFd_ > 0);
|
||||
int ret = ::listen(sockFd_, SOMAXCONN);
|
||||
if (ret < 0) {
|
||||
LOG_SYSERR << "listen failed";
|
||||
//LOG_SYSERR << "listen failed";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
@ -94,7 +93,7 @@ void Socket::closeWrite() {
|
||||
if (::shutdown(sockFd_, SD_SEND) < 0)
|
||||
#endif
|
||||
{
|
||||
LOG_SYSERR << "sockets::shutdownWrite";
|
||||
//LOG_SYSERR << "sockets::shutdownWrite";
|
||||
}
|
||||
}
|
||||
int Socket::read(char *buffer, uint64_t len) {
|
||||
@ -112,7 +111,7 @@ struct sockaddr_in6 Socket::getLocalAddr(int sockfd) {
|
||||
if (::getsockname(sockfd,
|
||||
static_cast<struct sockaddr *>((void *)(&localaddr)),
|
||||
&addrlen) < 0) {
|
||||
LOG_SYSERR << "sockets::getLocalAddr";
|
||||
//LOG_SYSERR << "sockets::getLocalAddr";
|
||||
}
|
||||
return localaddr;
|
||||
}
|
||||
@ -124,7 +123,7 @@ struct sockaddr_in6 Socket::getPeerAddr(int sockfd) {
|
||||
if (::getpeername(sockfd,
|
||||
static_cast<struct sockaddr *>((void *)(&peeraddr)),
|
||||
&addrlen) < 0) {
|
||||
LOG_SYSERR << "sockets::getPeerAddr";
|
||||
//LOG_SYSERR << "sockets::getPeerAddr";
|
||||
}
|
||||
return peeraddr;
|
||||
}
|
||||
@ -170,7 +169,7 @@ void Socket::setReusePort(bool on) {
|
||||
&optval,
|
||||
static_cast<socklen_t>(sizeof optval));
|
||||
if (ret < 0 && on) {
|
||||
LOG_SYSERR << "SO_REUSEPORT failed.";
|
||||
//LOG_SYSERR << "SO_REUSEPORT failed.";
|
||||
}
|
||||
#else
|
||||
if (on) {
|
@ -12,6 +12,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
// TODO Re enable logging
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <trantor/utils/NonCopyable.h>
|
@ -19,7 +19,7 @@
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
|
||||
#include "Socket.h"
|
||||
#include "core/net/socket.h"
|
||||
|
||||
#include <stdio.h> // snprintf
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
#include <trantor/net/EventLoop.h>
|
||||
#include <trantor/utils/NonCopyable.h>
|
||||
#include "Socket.h"
|
||||
#include "core/net/socket.h"
|
||||
#include "core/net/inet_address.h"
|
||||
#include "Channel.h"
|
||||
#include <functional>
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
#include "Connector.h"
|
||||
#include "Channel.h"
|
||||
#include "Socket.h"
|
||||
#include "core/net/socket.h"
|
||||
|
||||
using namespace trantor;
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
#include "TcpConnectionImpl.h"
|
||||
#include "Channel.h"
|
||||
#include "Socket.h"
|
||||
#include "core/net/socket.h"
|
||||
#ifdef __linux__
|
||||
#include <sys/sendfile.h>
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user