9 #ifndef __SHAWN_APPS_TCPIP_SOCKET_H 10 #define __SHAWN_APPS_TCPIP_SOCKET_H 13 #include <shawn_config.h> 14 #include "_apps_enable_cmake.h" 27 #include <apps/tcpip/storage.h> 34 {
class SimulationController; }
37 extern "C" void init_tcpip( shawn::SimulationController& );
62 friend class Response;
65 Socket(std::string host,
int port);
75 static int getFreeSocketPort();
81 Socket* accept(
const bool create =
false);
83 void send(
const std::vector<unsigned char> &buffer);
84 void sendExact(
const Storage & );
86 std::vector<unsigned char> receive(
int bufSize = 2048 );
91 void set_blocking(
bool);
93 bool has_client_connection()
const;
104 void receiveComplete(
unsigned char *
const buffer, std::size_t len)
const;
106 size_t recvAndCheck(
unsigned char *
const buffer, std::size_t len)
const;
108 void printBufferOnVerbose(
const std::vector<unsigned char> buffer,
const std::string &label)
const;
112 static void BailOnSocketError(std::string context);
114 static std::string GetWinsockErrorString(
int err);
116 bool atoaddr(std::string,
struct sockaddr_in& addr);
117 bool datawaiting(
int sock)
const;
127 static bool init_windows_sockets_;
128 static bool windows_sockets_initialized_;
129 static int instance_count_;
135 #endif // BUILD_TCPIP
SocketException(std::string what)
static const int lengthLen
Length of the message length part of a TraCI message.
void set_verbose(bool newVerbose)