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& );
42 #pragma warning( disable : 4290 ) 70 virtual const char*
what()
const throw()
80 friend class Response;
83 Socket(std::string host,
int port);
95 Socket* accept(const
bool create = false) throw(SocketException);
97 void send( const std::vector<
unsigned char> &buffer) throw( SocketException );
98 void sendExact( const
Storage & ) throw( SocketException );
100 std::vector<
unsigned char> receive(
int bufSize = 2048 ) throw( SocketException );
102 bool receiveExact(
Storage &) throw( SocketException );
105 void set_blocking(
bool) throw( SocketException );
106 bool is_blocking() throw();
107 bool has_client_connection() const;
110 bool verbose() {
return verbose_; }
118 void receiveComplete(
unsigned char *
const buffer, std::size_t len)
const;
120 size_t recvAndCheck(
unsigned char *
const buffer, std::size_t len)
const;
122 void printBufferOnVerbose(
const std::vector<unsigned char> buffer,
const std::string &label)
const;
128 std::string GetWinsockErrorString(
int err)
const;
130 bool atoaddr(std::string,
struct sockaddr_in& addr);
131 bool datawaiting(
int sock)
const throw();
141 static bool init_windows_sockets_;
142 static bool windows_sockets_initialized_;
143 static int instance_count_;
149 #endif // BUILD_TCPIP
SocketException(std::string what)
static const int lengthLen
Length of the message length part of a TraCI message.
virtual const char * what() const
void set_verbose(bool newVerbose)