udp.h
上传用户:maryhy001
上传日期:2007-05-02
资源大小:2317k
文件大小:1k
- //udp.h : CUDPServer and CUDPClient class define here.
- //
- #ifndef _NETUDP_H
- #define _NETUDP_H
- class NETLIBDLLEXPORT CUDPSocket
- {
- public:
- CUDPSocket();
- virtual ~CUDPSocket();
- virtual bool Create(int nUDPPort, int nRecvTimeout = -1, int nSendTimeout = -1) = 0;
- virtual void Destroy(void);
- SOCKET getSocketHandle(void);
- bool socketIsValid(void);
- int getPort(void);
- int getRecvTimeout(void);
- int getSendTimeout(void);
- int Read(SOCKADDR_IN &from, char *lpsbuf, int len);
- int Write(const char *lpcstoaddr, char *lpsbuf, int len);
- int Write(const SOCKADDR_IN &to, char *lpsbuf, int len);
- protected:
- SOCKET m_hsock;
- int m_nport;
- int m_nRecvTimeout,
- m_nSendTimeout;
- };
- class NETLIBDLLEXPORT CUDPServer : public CUDPSocket
- {
- public:
- CUDPServer();
- ~CUDPServer();
- bool Create(int nUDPPort, int nRecvTimeout = -1, int nSendTimeout = -1);
- };
- class NETLIBDLLEXPORT CUDPClient : public CUDPSocket
- {
- public:
- CUDPClient();
- ~CUDPClient();
- bool Create(int nUDPPort, int nRecvTimeout = -1, int nSendTimeout = -1);
- };
- #endif //!_NETUDP_H