@@ -58,7 +58,7 @@ bool Socket::create(int family, int socktype, int protocol)
5858 return raw_socket != INVALID_SOCKET;
5959}
6060
61- bool connect_socket (Socket& socket, const char * port, const char * remote)
61+ bool connect_socket (Socket& socket, const char * port, const char * remote, bool yell = false )
6262{
6363
6464 struct addrinfo * result = NULL ;
@@ -75,14 +75,14 @@ bool connect_socket(Socket& socket, const char* port, const char* remote)
7575 iResult = getaddrinfo (remote, port, &hints, &result);
7676 if (iResult != 0 )
7777 {
78- Core::Alert (" getaddrinfo failed with error: " + std::to_string (iResult));
78+ if (yell) Core::Alert (" getaddrinfo failed with error: " + std::to_string (iResult));
7979 return false ;
8080 }
8181
8282 // Create a SOCKET for connecting to server
8383 if (!socket.create (result->ai_family , result->ai_socktype , result->ai_protocol ))
8484 {
85- Core::Alert (" socket failed with error: " + std::to_string (WSAGetLastError ()));
85+ if (yell) Core::Alert (" socket failed with error: " + std::to_string (WSAGetLastError ()));
8686 freeaddrinfo (result);
8787 return false ;
8888 }
@@ -91,7 +91,7 @@ bool connect_socket(Socket& socket, const char* port, const char* remote)
9191 iResult = ::connect (socket.raw (), result->ai_addr , (int )result->ai_addrlen );
9292 if (iResult == SOCKET_ERROR)
9393 {
94- Core::Alert (" connect failed with error: " + std::to_string (WSAGetLastError ()));
94+ if (yell) Core::Alert (" connect failed with error: " + std::to_string (WSAGetLastError ()));
9595 freeaddrinfo (result);
9696 socket.close ();
9797 return false ;
@@ -176,7 +176,7 @@ bool JsonStream::connect(const char* port, const char* remote)
176176 return false ;
177177 }
178178
179- return connect_socket (socket, port, remote);
179+ return connect_socket (socket, port, remote, true );
180180}
181181
182182bool JsonStream::send (const char * type, nlohmann::json content)
@@ -190,7 +190,7 @@ bool JsonStream::send(const char* type, nlohmann::json content)
190190
191191bool JsonStream::send (nlohmann::json j)
192192{
193- std::string data = j.dump ();
193+ std::string data = j.dump (- 1 , ' ' , false , nlohmann::json:: error_handler_t ::replace );
194194 data.push_back (0 );
195195 while (!data.empty ())
196196 {
0 commit comments