Replaced log macro with offical baka logging system

multi_plaform
anulax1225 ago%!(EXTRA string=1 year)
parent 5bbec9ba92
commit 82d8f904fa
  1. 1
      bakanet/src/bakanetpch.h
  2. 7
      bakanet/src/platform/linux/linux_socket.cpp
  3. 1
      bakanet/src/platform/linux/linux_socket.h
  4. 8
      bakanet/src/platform/windows/windows_socket.cpp

@ -18,6 +18,7 @@
#include <tchar.h>
#pragma comment(lib,"WS2_32.lib")
#elif defined(BK_PLATFORM_LINUX)
#include <stdio.h>
#include <netinet/in.h>
#include <stdlib.h>
#include <sys/socket.h>

@ -17,7 +17,7 @@ namespace Bk::Net {
//LinuxSocket creation step
if ((id = socket((int)ip_addr.version, (int)ip_proto, 0)) < 0)
{
perror("socket failed");
BK_CORE_TRACE("Socket failed : {0}", strerror(errno));
exit(EXIT_FAILURE);
}
addr.sin_addr = ip_addr.get_data();
@ -36,7 +36,7 @@ namespace Bk::Net {
int status;
if ((status = bind(id, (struct sockaddr*)&addr, sizeof(addr)) < 0))
{
perror("bind failed");
BK_CORE_TRACE("Binding failed : {0}", strerror(errno));
return false;
}
return true;
@ -47,6 +47,7 @@ namespace Bk::Net {
//Listening step
if (listen(id, cpt_conn) < 0)
{
BK_CORE_TRACE("Listening failed : {0}", strerror(errno));
return false;
}
return true;
@ -54,7 +55,6 @@ namespace Bk::Net {
std::unique_ptr<Socket> LinuxSocket::ack()
{
socklen_t addrlen = sizeof(addr);
return std::unique_ptr<Socket>(Socket::create(accept(id, (struct sockaddr*)&addr, &addrlen), ip_addr.version, ip_proto));
}
@ -63,6 +63,7 @@ namespace Bk::Net {
{
if (connect(id, (struct sockaddr*)&addr, sizeof(addr)) < 0)
{
BK_CORE_TRACE("Connection failed : {0}", strerror(errno));
return false;
}
return true;

@ -1,5 +1,6 @@
#pragma once
#include <bakatools.h>
#include <bakanet/core/socket.h>
namespace Bk::Net {

@ -24,7 +24,7 @@ namespace Bk::Net {
err = WSAStartup(MAKEWORD(2, 2), &wsa_data);
if (err != 0)
{
log("WSA failed " << WSAGetLastError());
BK_CORE_TRACE("WSA failed : {0}", WSAGetLastError());
WSACleanup();
exit(EXIT_FAILURE);
}
@ -33,7 +33,7 @@ namespace Bk::Net {
//WindowsSocket creation step
if ((id = (int)socket((int)ip_addr.version, (int)ip_proto, 0)) < 0)
{
log("socket failed " << WSAGetLastError());
BK_CORE_TRACE("Socket failed : {0}", WSAGetLastError());
exit(EXIT_FAILURE);
}
addr.sin_addr = ip_addr.get_data();
@ -53,7 +53,7 @@ namespace Bk::Net {
int status;
if ((status = bind((SOCKET)id, (struct sockaddr*)&addr, sizeof(addr)) < 0))
{
log("bind failed " << WSAGetLastError());
BK_CORE_TRACE("Binding failed : {0}", WSAGetLastError());
return false;
}
return true;
@ -62,7 +62,7 @@ namespace Bk::Net {
bool WindowsSocket::start(int cpt_conn = SOMAXCONN)
{
//Listening step
if (listen(id, cpt_conn) == SOCKET_ERROR) { return false; }
if (listen(id, cpt_conn) == SOCKET_ERROR) { BK_CORE_TRACE("Listening failed : {0}", WSAGetLastError()); return false; }
return true;
}

Loading…
Cancel
Save