Beginning to make base loop
This commit is contained in:
parent
e8aa00ca82
commit
29fb686d40
3 changed files with 20 additions and 15 deletions
|
|
@ -31,21 +31,22 @@ int Socket::winInit()
|
||||||
int Socket::winBind()
|
int Socket::winBind()
|
||||||
{
|
{
|
||||||
if (bind(mainSocket, (SOCKADDR*)&service, sizeof(service)) == SOCKET_ERROR) {
|
if (bind(mainSocket, (SOCKADDR*)&service, sizeof(service)) == SOCKET_ERROR) {
|
||||||
log.err("Network.Socket.winInit: Bind failed: " + std::to_string(WSAGetLastError()));
|
log.err("Network.Socket.winInit: Bind failed: " + std::to_string(WSAGetLastError()));
|
||||||
closesocket(mainSocket);
|
closesocket(mainSocket);
|
||||||
return 1;
|
|
||||||
}
|
return 1;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Socket::winListen()
|
int Socket::winListen()
|
||||||
{
|
{
|
||||||
if (listen(mainSocket, SOMAXCONN) == SOCKET_ERROR) {
|
if (listen(mainSocket, SOMAXCONN) == SOCKET_ERROR) {
|
||||||
log.err("Network.Socket.winInit: Listen failed: " + std::to_string(WSAGetLastError()));
|
log.err("Network.Socket.winInit: Listen failed: " + std::to_string(WSAGetLastError()));
|
||||||
closesocket(mainSocket);
|
closesocket(mainSocket);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("Network.Socket.winInit: Listening on " + std::string(NET_SOCK_ADDR) + ":" + std::to_string(NET_SOCK_PORT));
|
log.info("Network.Socket.winInit: Listening on " + std::string(NET_SOCK_ADDR) + ":" + std::to_string(NET_SOCK_PORT));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -16,7 +16,7 @@ public:
|
||||||
int pBind();
|
int pBind();
|
||||||
int pListen();
|
int pListen();
|
||||||
|
|
||||||
int winInit();
|
int winInit();
|
||||||
int winBind();
|
int winBind();
|
||||||
int winListen();
|
int winListen();
|
||||||
};
|
};
|
||||||
|
|
@ -3,8 +3,7 @@
|
||||||
|
|
||||||
#include <winsock.h>
|
#include <winsock.h>
|
||||||
|
|
||||||
#define NET_SOCK_ADDR "0.0.0.0"
|
bool running = false;
|
||||||
#define NET_SOCK_PORT 25565
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
@ -14,6 +13,11 @@ int main() {
|
||||||
log.raw("mcc v0.0.0");
|
log.raw("mcc v0.0.0");
|
||||||
Socket socket;
|
Socket socket;
|
||||||
socket.winInit();
|
socket.winInit();
|
||||||
|
socket.winBind();
|
||||||
|
running = true;
|
||||||
|
while(running){
|
||||||
|
socket.winListen();
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue