Go to the documentation of this file.00001 #pragma once
00002
00007 namespace AppSecInc
00008 {
00009 namespace TcpIp
00010 {
00011 namespace Sockets
00012 {
00019 class Socket
00020 {
00021 protected:
00022 SOCKET m_socket;
00023 int m_error;
00024 bool m_connected;
00026 virtual void InternalSetSockOpt(int level, int optname, const char * optval, int optlen);
00028 virtual void InternalIoCtlSocket(long cmd, u_long * argp);
00030 virtual void InternalCreate(int af = AF_INET, int type = SOCK_STREAM, int protocol = IPPROTO_IP, LPWSAPROTOCOL_INFO lpProtocolInfo = NULL, GROUP g = NULL, DWORD dwFlags = 0);
00032 virtual void InternalConnect(const struct sockaddr * name, int namelen, LPWSABUF lpCallerData = NULL, LPWSABUF lpCalleeData = NULL, LPQOS lpSQOS = NULL, LPQOS lpGQOS = NULL);
00034 virtual void InternalShutdown(int how);
00036 virtual void InternalClose();
00037 public:
00040 int GetError() const { return m_error; }
00042 void ClearError() { m_error = 0; }
00044 SOCKET Peek() const { return m_socket; }
00046 bool IsCreated() const { return (m_socket != INVALID_SOCKET); }
00048 bool IsConnected() const { return m_connected; }
00050 void Select(bool read, bool write, bool except, const int timeout_in_seconds, bool& timed_out);
00052 void SetHardClose(unsigned short timeout = 0);
00054 void SetGracefulClose();
00056 void SetSocketReuse();
00058 void Socket::Connect(const std::wstring& ip_addr, unsigned port, int type = SOCK_STREAM, int protocol = IPPROTO_IP);
00060 void Connect(const std::string& ip_addr, unsigned port, int type = SOCK_STREAM, int protocol = IPPROTO_IP);
00062 void Connect(const struct sockaddr * name, int namelen);
00064 void Disconnect();
00066 void Bind(const std::string& ip_addr, unsigned port, int type = SOCK_STREAM, int protocol = IPPROTO_IP);
00068 Socket();
00069 virtual ~Socket();
00070 };
00071 }
00072 }
00073 }