diff options
author | Mike Buland <eichlan@xagasoft.com> | 2011-01-20 18:09:04 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2011-01-20 18:09:04 +0000 |
commit | 393f1b414746a7f1977971dd7659dd2b47092b11 (patch) | |
tree | 81d0ca1ee70ab86a7d79c1991abe5c387b655fb2 /src/udpsocket.cpp | |
parent | c259f95bd0e58b247940a339bb9b4b401b4e9438 (diff) | |
parent | 7e25a863325dc3e9762397e700030969e093b087 (diff) | |
download | libbu++-393f1b414746a7f1977971dd7659dd2b47092b11.tar.gz libbu++-393f1b414746a7f1977971dd7659dd2b47092b11.tar.bz2 libbu++-393f1b414746a7f1977971dd7659dd2b47092b11.tar.xz libbu++-393f1b414746a7f1977971dd7659dd2b47092b11.zip |
Wow! Merged the branch, streams are updated, and there's no more FString, run
the fixstrings.sh script in the support directory to (hopefully) automatically
update your projects.
Diffstat (limited to 'src/udpsocket.cpp')
-rw-r--r-- | src/udpsocket.cpp | 46 |
1 files changed, 34 insertions, 12 deletions
diff --git a/src/udpsocket.cpp b/src/udpsocket.cpp index da57b8d..91e04c1 100644 --- a/src/udpsocket.cpp +++ b/src/udpsocket.cpp | |||
@@ -1,3 +1,10 @@ | |||
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 | |||
1 | #include "bu/udpsocket.h" | 8 | #include "bu/udpsocket.h" |
2 | 9 | ||
3 | #include "bu/sio.h" | 10 | #include "bu/sio.h" |
@@ -21,7 +28,7 @@ Bu::UdpSocket::UdpSocket( int iUdpSocket ) : | |||
21 | { | 28 | { |
22 | } | 29 | } |
23 | 30 | ||
24 | Bu::UdpSocket::UdpSocket( const Bu::FString &sAddr, int iPort, int iFlags ) : | 31 | Bu::UdpSocket::UdpSocket( const Bu::String &sAddr, int iPort, int iFlags ) : |
25 | iUdpSocket( 0 ), | 32 | iUdpSocket( 0 ), |
26 | paTarget( NULL ), | 33 | paTarget( NULL ), |
27 | bBound( false ) | 34 | bBound( false ) |
@@ -72,9 +79,9 @@ Bu::UdpSocket::~UdpSocket() | |||
72 | paTarget = NULL; | 79 | paTarget = NULL; |
73 | } | 80 | } |
74 | 81 | ||
75 | Bu::FString Bu::UdpSocket::addrToStr( const addr &a ) | 82 | Bu::String Bu::UdpSocket::addrToStr( const addr &a ) |
76 | { | 83 | { |
77 | Bu::FString sOut; | 84 | Bu::String sOut; |
78 | sOut.format("%d.%d.%d.%d", | 85 | sOut.format("%d.%d.%d.%d", |
79 | (a&0xff), | 86 | (a&0xff), |
80 | (a&0xff00)>>8, | 87 | (a&0xff00)>>8, |
@@ -90,24 +97,24 @@ void Bu::UdpSocket::close() | |||
90 | ::close( iUdpSocket ); | 97 | ::close( iUdpSocket ); |
91 | } | 98 | } |
92 | 99 | ||
93 | size_t Bu::UdpSocket::read( void *pBuf, size_t nBytes ) | 100 | Bu::size Bu::UdpSocket::read( void *pBuf, Bu::size nBytes ) |
94 | { | 101 | { |
95 | return recv( iUdpSocket, pBuf, nBytes, 0 ); | 102 | return recv( iUdpSocket, pBuf, nBytes, 0 ); |
96 | } | 103 | } |
97 | 104 | ||
98 | size_t Bu::UdpSocket::read( void *pBuf, size_t nBytes, | 105 | Bu::size Bu::UdpSocket::read( void *pBuf, Bu::size nBytes, |
99 | Bu::UdpSocket::addr &aHost, int &iPort ) | 106 | Bu::UdpSocket::addr &aHost, int &iPort ) |
100 | { | 107 | { |
101 | sockaddr_in name; | 108 | sockaddr_in name; |
102 | size_t size = sizeof(name); | 109 | size_t size = sizeof(name); |
103 | size_t ret = recvfrom( iUdpSocket, pBuf, nBytes, 0, | 110 | Bu::size ret = recvfrom( iUdpSocket, pBuf, nBytes, 0, |
104 | (struct sockaddr *)&name, &size ); | 111 | (struct sockaddr *)&name, &size ); |
105 | aHost = name.sin_addr.s_addr; | 112 | aHost = name.sin_addr.s_addr; |
106 | iPort = ntohs(name.sin_port); | 113 | iPort = ntohs(name.sin_port); |
107 | return ret; | 114 | return ret; |
108 | } | 115 | } |
109 | 116 | ||
110 | size_t Bu::UdpSocket::write( const void *pBuf, size_t nBytes ) | 117 | Bu::size Bu::UdpSocket::write( const void *pBuf, Bu::size nBytes ) |
111 | { | 118 | { |
112 | if( bBound ) | 119 | if( bBound ) |
113 | { | 120 | { |
@@ -120,22 +127,22 @@ size_t Bu::UdpSocket::write( const void *pBuf, size_t nBytes ) | |||
120 | } | 127 | } |
121 | } | 128 | } |
122 | 129 | ||
123 | long Bu::UdpSocket::tell() | 130 | Bu::size Bu::UdpSocket::tell() |
124 | { | 131 | { |
125 | throw Bu::UnsupportedException(); | 132 | throw Bu::UnsupportedException(); |
126 | } | 133 | } |
127 | 134 | ||
128 | void Bu::UdpSocket::seek( long ) | 135 | void Bu::UdpSocket::seek( Bu::size ) |
129 | { | 136 | { |
130 | throw Bu::UnsupportedException(); | 137 | throw Bu::UnsupportedException(); |
131 | } | 138 | } |
132 | 139 | ||
133 | void Bu::UdpSocket::setPos( long ) | 140 | void Bu::UdpSocket::setPos( Bu::size ) |
134 | { | 141 | { |
135 | throw Bu::UnsupportedException(); | 142 | throw Bu::UnsupportedException(); |
136 | } | 143 | } |
137 | 144 | ||
138 | void Bu::UdpSocket::setPosEnd( long ) | 145 | void Bu::UdpSocket::setPosEnd( Bu::size ) |
139 | { | 146 | { |
140 | throw Bu::UnsupportedException(); | 147 | throw Bu::UnsupportedException(); |
141 | } | 148 | } |
@@ -211,7 +218,22 @@ void Bu::UdpSocket::setBlocking( bool bBlocking ) | |||
211 | #endif | 218 | #endif |
212 | } | 219 | } |
213 | 220 | ||
214 | void Bu::UdpSocket::setSize( long ) | 221 | void Bu::UdpSocket::setSize( Bu::size ) |
222 | { | ||
223 | throw Bu::UnsupportedException(); | ||
224 | } | ||
225 | |||
226 | Bu::size Bu::UdpSocket::getSize() const | ||
227 | { | ||
228 | throw Bu::UnsupportedException(); | ||
229 | } | ||
230 | |||
231 | Bu::size Bu::UdpSocket::getBlockSize() const | ||
232 | { | ||
233 | return 1500; | ||
234 | } | ||
235 | |||
236 | Bu::String Bu::UdpSocket::getLocation() const | ||
215 | { | 237 | { |
216 | throw Bu::UnsupportedException(); | 238 | throw Bu::UnsupportedException(); |
217 | } | 239 | } |