Skip to content

Commit

Permalink
win32 sync compiles and ... works...?
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaji Khan committed Nov 15, 2024
1 parent 234efd4 commit 164aade
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 5 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,5 @@ server.o: server.cc server.h client.cc client.h winserver.cc winserver.h
echo-client: echo-client.cc server.o
$(CPP) -o echo-client echo-client.cc client.cc $(GTK) -Wall

win-net: win_net.cc
$(CPP) -o win-net win_net.cc -lws2_32 -lwsock32
Binary file modified amprack.exe
Binary file not shown.
Binary file modified main.o
Binary file not shown.
Binary file modified sync.o
Binary file not shown.
2 changes: 1 addition & 1 deletion version.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define VERSION 156
#define VERSION 157
Binary file added win-net.exe
Binary file not shown.
3 changes: 2 additions & 1 deletion win_net.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <winsock2.h>
#include <boost/asio.hpp>
#include <boost/bind/bind.hpp>
#include <boost/optional.hpp>
Expand Down Expand Up @@ -75,7 +76,7 @@ void run_client() {

for (std::string msg : {"Hello World", "Bye World"}) {
write(m_Socket, asio::buffer(msg));
std::this_thread::sleep_for(100ms);
sleep(100);
}
} catch (std::exception& e) {
std::cerr << "Exception: " << e.what() << "\n";
Expand Down
9 changes: 7 additions & 2 deletions winserver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,28 @@ std::string Client::send_preset (json j) {
std::cerr << "Exception: " << e.what() << "\n";
}

return string ("");
return string ("{}}");
OUT
}

void Server::close_socket () {
g_main_loop_quit (main_loop);
ioc.stop();
ioc.join();
}

void Client::close_socket () {

}

Server::Server () {

}

void Server::run () {
IN
TheServer server(ioc.get_executor(), 6906);
main_loop = g_main_loop_new (null, true);
g_main_loop_run (main_loop);
OUT
}

6 changes: 5 additions & 1 deletion winserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,17 @@ class TheServer {
private:

void do_accept() {
IN
m_Acceptor.async_accept([this](boost::system::error_code ec, tcp::socket s) {
if (!ec) {
std::thread(read_session, std::move(s)).detach();
do_accept(); // and immediately accept new connection(s)
} else {
std::cout << "Connection error (" << ec.message() << ")" << std::endl;
//~ std::cout << "Connection error (" << ec.message() << ")" << std::endl;
LOGD ("connection error %s", ec.message ().c_str ());
}
});
OUT
}

tcp::acceptor m_Acceptor;
Expand Down Expand Up @@ -75,6 +78,7 @@ class Server {
void run();

GMainContext * context ;
GMainLoop * main_loop ;
void create();
void close_socket();
void serve();
Expand Down
Binary file modified winserver.o
Binary file not shown.

0 comments on commit 164aade

Please sign in to comment.