aboutsummaryrefslogtreecommitdiff
path: root/src/udpsocket.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/udpsocket.cpp')
-rw-r--r--src/udpsocket.cpp46
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
24Bu::UdpSocket::UdpSocket( const Bu::FString &sAddr, int iPort, int iFlags ) : 31Bu::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
75Bu::FString Bu::UdpSocket::addrToStr( const addr &a ) 82Bu::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
93size_t Bu::UdpSocket::read( void *pBuf, size_t nBytes ) 100Bu::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
98size_t Bu::UdpSocket::read( void *pBuf, size_t nBytes, 105Bu::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
110size_t Bu::UdpSocket::write( const void *pBuf, size_t nBytes ) 117Bu::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
123long Bu::UdpSocket::tell() 130Bu::size Bu::UdpSocket::tell()
124{ 131{
125 throw Bu::UnsupportedException(); 132 throw Bu::UnsupportedException();
126} 133}
127 134
128void Bu::UdpSocket::seek( long ) 135void Bu::UdpSocket::seek( Bu::size )
129{ 136{
130 throw Bu::UnsupportedException(); 137 throw Bu::UnsupportedException();
131} 138}
132 139
133void Bu::UdpSocket::setPos( long ) 140void Bu::UdpSocket::setPos( Bu::size )
134{ 141{
135 throw Bu::UnsupportedException(); 142 throw Bu::UnsupportedException();
136} 143}
137 144
138void Bu::UdpSocket::setPosEnd( long ) 145void 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
214void Bu::UdpSocket::setSize( long ) 221void Bu::UdpSocket::setSize( Bu::size )
222{
223 throw Bu::UnsupportedException();
224}
225
226Bu::size Bu::UdpSocket::getSize() const
227{
228 throw Bu::UnsupportedException();
229}
230
231Bu::size Bu::UdpSocket::getBlockSize() const
232{
233 return 1500;
234}
235
236Bu::String Bu::UdpSocket::getLocation() const
215{ 237{
216 throw Bu::UnsupportedException(); 238 throw Bu::UnsupportedException();
217} 239}