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& );
83 void send(
const std::vector<unsigned char> &buffer);
86 std::vector<unsigned char>
receive(
int bufSize = 2048 );
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;
114 static std::string GetWinsockErrorString(
int err);
126 static bool init_windows_sockets_;
127 static bool windows_sockets_initialized_;
128 static int instance_count_;
SocketException(std::string what)
void printBufferOnVerbose(const std::vector< unsigned char > buffer, const std::string &label) const
Print label and buffer to stderr if Socket::verbose_ is set.
bool receiveExact(Storage &)
Receive a complete TraCI message from Socket::socket_.
std::vector< unsigned char > receive(int bufSize=2048)
Receive up to bufSize available bytes from Socket::socket_.
bool datawaiting(int sock) const
size_t recvAndCheck(unsigned char *const buffer, std::size_t len) const
Receive up to len available bytes from Socket::socket_.
static void BailOnSocketError(std::string context)
static int getFreeSocketPort()
Returns an free port on the system.
void set_verbose(bool newVerbose)
void sendExact(const Storage &)
bool has_client_connection() const
void connect()
Connects to host_:port_.
static const int lengthLen
Length of the message length part of a TraCI message.
Socket * accept(const bool create=false)
Wait for a incoming connection to port_.
void receiveComplete(unsigned char *const buffer, std::size_t len) const
Receive len bytes from Socket::socket_.
void send(const std::vector< unsigned char > &buffer)