How to get wxSocketBase input data size? Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
DanRR
Knows some wx things
Knows some wx things
Posts: 31
Joined: Tue Nov 28, 2006 10:35 pm

How to get wxSocketBase input data size?

Post by DanRR »

Hello,

I want to use wxSocketServer to receive bindery data.
wxSocketBase::Read function may get me null-terminated data string, but how do I get the size of binary data (that may contain zeros)?
Is my only option is using something like this?:

Code: Select all

while(sock->IsData())
	sock->Read(buf[len++], 1);
  
FlyingIsFun1217
Super wx Problem Solver
Super wx Problem Solver
Posts: 497
Joined: Mon Nov 06, 2006 9:58 pm

Post by FlyingIsFun1217 »

sizeof()?

FlyingIsFun1217
DanRR
Knows some wx things
Knows some wx things
Posts: 31
Joined: Tue Nov 28, 2006 10:35 pm

Post by DanRR »

FlyingIsFun1217 wrote:sizeof()?

FlyingIsFun1217
Thanks but I didn't get it, sizeof what?
You should supply your buffer and its size to wxSocketBase::Read(). you can get the whole buffer at one shot if you know the socket's received data size, so my question was how to get this size, when dealing with binary data.
FlyingIsFun1217
Super wx Problem Solver
Super wx Problem Solver
Posts: 497
Joined: Mon Nov 06, 2006 9:58 pm

Post by FlyingIsFun1217 »

DanRR wrote: Thanks but I didn't get it, sizeof what?

Code: Select all

sizeof(binData);
SizeOf().

FlyingIsFun1217 :)
mc2r
wxWorld Domination!
wxWorld Domination!
Posts: 1195
Joined: Thu Feb 22, 2007 4:47 pm
Location: Denver, Co
Contact:

Re: How to get wxSocketBase input data size?

Post by mc2r »

Code: Select all

while(sock && sock->IsData()){ // Don't call a member of a pointer if the pointer isn't valid
	sock->Read(buf, sizeof(buf));  // Read in bytes upto the size of buffer
	wxUint32 bytesRead = sock->LastCount();  // How many bytes were read in.
}
-Max
DanRR
Knows some wx things
Knows some wx things
Posts: 31
Joined: Tue Nov 28, 2006 10:35 pm

Re: How to get wxSocketBase input data size?

Post by DanRR »

mc2r wrote:

Code: Select all

while(sock && sock->IsData()){ // Don't call a member of a pointer if the pointer isn't valid
	sock->Read(buf, sizeof(buf));  // Read in bytes upto the size of buffer
	wxUint32 bytesRead = sock->LastCount();  // How many bytes were read in.
}
-Max
Thanks!
For some reason, I missed that LastCount() :D
Post Reply