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);
77 Socket* accept(
const bool create =
false);
79 void send(
const std::vector<unsigned char> &buffer);
80 void sendExact(
const Storage & );
82 std::vector<unsigned char> receive(
int bufSize = 2048 );
87 void set_blocking(
bool);
89 bool has_client_connection()
const;
100 void receiveComplete(
unsigned char *
const buffer, std::size_t len)
const;
102 size_t recvAndCheck(
unsigned char *
const buffer, std::size_t len)
const;
104 void printBufferOnVerbose(
const std::vector<unsigned char> buffer,
const std::string &label)
const;
108 void BailOnSocketError(std::string context)
const;
110 std::string GetWinsockErrorString(
int err)
const;
112 bool atoaddr(std::string,
struct sockaddr_in& addr);
113 bool datawaiting(
int sock)
const;
123 static bool init_windows_sockets_;
124 static bool windows_sockets_initialized_;
125 static int instance_count_;
131 #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)