diff options
author | Mike Buland <eichlan@xagasoft.com> | 2012-03-25 20:00:08 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2012-03-25 20:00:08 +0000 |
commit | 469bbcf0701e1eb8a6670c23145b0da87357e178 (patch) | |
tree | b5b062a16e46a6c5d3410b4e574cd0cc09057211 /src/unstable/udpsocket.h | |
parent | ee1b79396076edc4e30aefb285fada03bb45e80d (diff) | |
download | libbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.tar.gz libbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.tar.bz2 libbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.tar.xz libbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.zip |
Code is all reorganized. We're about ready to release. I should write up a
little explenation of the arrangement.
Diffstat (limited to 'src/unstable/udpsocket.h')
-rw-r--r-- | src/unstable/udpsocket.h | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/src/unstable/udpsocket.h b/src/unstable/udpsocket.h new file mode 100644 index 0000000..f228f08 --- /dev/null +++ b/src/unstable/udpsocket.h | |||
@@ -0,0 +1,84 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007-2011 Xagasoft, All rights reserved. | ||
3 | * | ||
4 | * This file is part of the libbu++ library and is released under the | ||
5 | * terms of the license contained in the file LICENSE. | ||
6 | */ | ||
7 | #ifndef WIN32 //not on windows | ||
8 | |||
9 | #ifndef BU_UDP_SOCKET_H | ||
10 | #define BU_UDP_SOCKET_H | ||
11 | |||
12 | #include <stdint.h> | ||
13 | |||
14 | #include "bu/stream.h" | ||
15 | |||
16 | namespace Bu | ||
17 | { | ||
18 | subExceptionDecl( UdpSocketException ); | ||
19 | |||
20 | class UdpSocket : public Stream | ||
21 | { | ||
22 | public: | ||
23 | UdpSocket( int iUdpSocket ); | ||
24 | UdpSocket( const Bu::String &sAddr, int iPort, int iFlags ); | ||
25 | virtual ~UdpSocket(); | ||
26 | |||
27 | typedef uint32_t addr; | ||
28 | |||
29 | static Bu::String addrToStr( const addr &a ); | ||
30 | |||
31 | virtual void close(); | ||
32 | virtual Bu::size read( void *pBuf, Bu::size nBytes ); | ||
33 | virtual Bu::size read( void *pBuf, Bu::size nBytes, | ||
34 | addr &sHost, int &iPort ); | ||
35 | virtual Bu::size write( const void *pBuf, Bu::size nBytes ); | ||
36 | using Stream::write; | ||
37 | |||
38 | virtual Bu::size tell(); | ||
39 | virtual void seek( Bu::size offset ); | ||
40 | virtual void setPos( Bu::size pos ); | ||
41 | virtual void setPosEnd( Bu::size pos ); | ||
42 | virtual bool isEos(); | ||
43 | virtual bool isOpen(); | ||
44 | |||
45 | virtual void flush(); | ||
46 | |||
47 | virtual bool canRead(); | ||
48 | virtual bool canWrite(); | ||
49 | |||
50 | virtual bool isReadable(); | ||
51 | virtual bool isWritable(); | ||
52 | virtual bool isSeekable(); | ||
53 | |||
54 | virtual bool isBlocking(); | ||
55 | virtual void setBlocking( bool bBlocking=true ); | ||
56 | |||
57 | virtual void setSize( Bu::size iSize ); | ||
58 | |||
59 | enum { | ||
60 | // Flags | ||
61 | Read = 0x01, ///< Open udp socket for reading | ||
62 | Write = 0x02, ///< Open udp socket for writing | ||
63 | ReadWrite = 0x03, ///< Open for both read and write | ||
64 | Broadcast = 0x04, ///< Open for broadcast | ||
65 | }; | ||
66 | |||
67 | virtual size getSize() const; | ||
68 | virtual size getBlockSize() const; | ||
69 | virtual Bu::String getLocation() const; | ||
70 | |||
71 | private: | ||
72 | #ifdef WIN32 | ||
73 | unsigned int iUdpSocket; | ||
74 | #else | ||
75 | int iUdpSocket; | ||
76 | #endif | ||
77 | void *paTarget; | ||
78 | bool bBound; | ||
79 | }; | ||
80 | }; | ||
81 | |||
82 | #endif | ||
83 | |||
84 | #endif | ||