« first day (98 days earlier)      last day (2751 days later) » 

3:31 AM
@milleniumbug Hey man, I've seen alot of SDL code use the bitwise & to check for if a certain flag is on? for example, let say we do this int flag = SDL_GetWindowFlags(window); and then we do if(flags & SDL_WINDOW_FULLSCREEN) blah Why does this work? Can you give an example?
 
 
2 hours later…
5:16 AM
check out bitflags
 
5:59 AM
i think I broke my gcc or something....
and when I compile all I get is the pragma once warning... im compiling with this line: :!gcc -std=c++11 Stations.cpp Stations.h
I should add that the main function is located in the Stations.cpp file out of the w2 namespace
 
6:33 AM
Don't compile header files
Also your code is broken beyond belief
sizeof yields a compile time constant
You pass an uninitialized variable to std::istream::getline
Also don't use using namespace inside header files
Use std::getline(std::istream&, std::string&, char) instead of the member function std::istream::getline
And use std::string because it's way better
 
7:07 AM
yah i fixed my code well all the stuff that doesnt make sense but in my gcc it still doesnt spit anything back to me, just the pragma warning and thats it; updated code I've been testing on coliru: coliru.stacked-crooked.com/a/f774c2f5f0dc7fe6
i know string would be better but its for a lab so I have to follow their instructions
im just not sure why my complier isnt saying anything back; prnt.sc/cv9qri
it should just print test but its not
 
41 mins ago, by milleniumbug
Don't compile header files
 
i did that too still doesn;t print anything
 
compiler doesn't run your code - it produces an executable file
 
7:22 AM
if ran code in gvim before though
the -o command didnt change anything
unless im running the gcc command wrong?
 
-o switch changes the name of the output file
 
how would I compile it then?
so it would also run in gvim
 
Look how coliru does it
 
oh && ./a.out
thanks!
 
 
3 hours later…
10:47 AM
I'm trying to make a streaming application using boost with iostream, but the server is not separating the image frames
in the receive loop, is getting everything in one file.
The only solution i could find was sent a frame for connection, but is leaving the streaming very slow.
anyone have any idea for this problem?
 
@Melissia_M Yup. Add explicit framing. If stuck, see Stack Overflow
2 messages moved from Lounge<C++>
 
@Melissia_M a stream is just a stream of bytes, you are going to need to find a way to delimit the frames like either prefixing each frame with the size of it or adding some kind of delimiter like a sequence of bytes that a frame cannot contain.
 
@ratchetfreak the problem is that I am using iostream like that:
std::ifstream ifs("screen.jpg", std::ios::binary);
out << ifs.rdbuf();
 
nwp
@Melissia_M why exactly is that the problem?
 
11:02 AM
@nwp the right would be in each loop the file is closed, and start getting the next ,right? but the server does not close the file, continue to receive the other in the same.
 
nwp
@Melissia_M The ifs gets closed, the out doesn't, right?
 
@nwp I can post a piece of code here?
 
nwp
sure
try to hit the "Fixed font" button to get somewhat better formatting
 
@nwp

send_frame() {
boost::scoped_ptr<screenshot> ptr_screen(new screenshot);
handle_connection = true;

boost::asio::io_service svc;

boost::asio::ip::tcp::iostream stream_(boost::asio::ip::tcp::resolver::query{ "127.0.0.1", "6576" });

boost::iostreams::filtering_ostream out;
out.push(boost::iostreams::zlib_compressor());
out.push(stream_);

while (handle_connection) {
ptr_screen->Start();

std::ifstream ifs("screen.jpg", std::ios::binary);
out << ifs.rdbuf();
out.flush();
}
}
this is the client side
 
nwp
This ifs.rdbuf looks odd. I don't think it does the right thing.
 
11:09 AM
@nwp void receive_frame()
{
    connection_handle = true;
    try
    {
        boost::asio::io_service io_service;

        boost::asio::ip::tcp::endpoint endpoint(boost::asio::ip::tcp::v4(), 6576);
		boost::asio::ip::tcp::acceptor acceptor(io_service, endpoint);

		boost::asio::ip::tcp::iostream stream;
		boost::system::error_code ec;
		acceptor.accept(*stream.rdbuf(), ec);

        while(connection_handle)
        {
			boost::iostreams::filtering_istream in;
            in.push(boost::iostreams::zlib_decompressor());
 
nwp
no fixed font :(
 
sry
any idea for this problem?
 
nwp
No, I don't know the problem anymore. It is not that you send multiple images because you only send 1 image and then close the connection, so you know when the image ends.
Is the problem that "/tmp/img.jpg" gets overwritten every time you get a connection?
 
I want is for it to be overwritten
the problem is that it is not being overwritten
the server is on the same iteration and does not go to next
when I make a connection for file works quiet
 
nwp
What is connection_handle? Looks like a bool that is true forever. Is that intended?
You probably need to accept a new connection inside the loop.
 
11:18 AM
when the server hit enter, the connection_handle go false
I've done it, but the streaming is getting very slow getting one file per connection
work fine in local netwrok, but remotely it is bad
 
nwp
ok, so currently you are sending 1 file per connection and everything works (slowly)
 
yes
 
nwp
you now want to change it to send multiple files per connection
 
exactly, I think so will be better
 
nwp
so, you will have to do the delimiter thing
 
11:21 AM
I think it will be faster, I do not know ...
 
nwp
I would say you limit yourself to images that are smaller than 4GB and just send a 4 byte size of the image first, then the image, then the next size and the image and so on.
so the sender needs to send the size first and the receiver needs to read the size and then only read that many bytes into the file before switching to a new file
 
the size of the images are varied
I know how to do this using socket, but with iostream i do not know
the advantage to continue using iostream is that the images are compressed using zlib
 
nwp
you can use seekg + tellg to find out the size on the client side
ah, now I get it
the size of the image doesn't help, because it gets compressed, and you need the compressed size
although... that should handle itself when you just read from the stream
no, it should be fine sending the uncompressed size because you read uncompressed data and when you read 100 bytes you read 100 bytes of uncompressed data, so it should work
 
one of the reasons I'm using iostream is the ease of use of data compression, that improves performance speed in streaming
 
nwp
did you try the size thing? It should work with compression.
 
11:29 AM
I did not understand
calculate the file size and send as header?
for the server
 
nwp
right
 
i dit it with socket.
my old application did it
but the old application was slow because of not having data compression, and now I'm trying to do the same with iostream and zlib
it makes no sense the server does not overwrite the file frame...
 
nwp
@Melissia_M I don't understand that part.
 
solve this problem is boring. : /
if I ask a question on the site, everyone is going to dislike, but okay.
 
nwp
SO only likes clear questions with clear answers that have value to thousands of future visitors. "Help me send compressed images over the internet" doesn't qualify.
 
11:43 AM
@nwp i understand
 
 
11 hours later…
10:38 PM
apparently formatting as code is hard
http://pastebin.com/pLg8gLPV
I have a struct with a pointer inside that doesn't seem to update properly. Any troubleshooting tips would be appreciated.
 
4 messages moved from Lounge<C++>
 
What does your debugger say?
 
@deadbeef np at all
 
Try printing the values of things after you modify them.
 
I did that, it doesn't change the values within the function. Am I not passing the variable to it by reference? When I go to print out hash.cat inside the function I get a memory address.
 
10:47 PM
@deadbeef Do you know whether you pass that Node by value or by reference? Which of the two do you think it is, currently?
@deadbeef Ah what timing. What do you /think/, currently?
Because the answer is simple, but you should make that verdict yourself if you want to understand your own program
There's several mistakes involved, but let's start with the one
 
@deadbeef "When I go to print out hash.cat inside the function I get a memory address." Is it the same or different than the value it had prior to ++?
 
oh gosh I'm changing the memory address
 
Let me help you @deadbeef. In C++ /everything/ is passed by value. Unless you specificly specify a reference type (T&, so int& or Node&)
@deadbeef Good job. That was the second one of the mistakes! So, you're done. Now just need to fix both
 
brb switching to a liberal arts major
9
 
I am/was a liberal arts major.
 
10:52 PM
@sehe But then you saw the light. ;)
 
Actually. In this case, passing by reference doesn't matter much, because passing by value copies the pointer, but it will still be the pointer you need/expect
@GManNickG Not really. I never could choose
 
One bit, I think I see my mistake. I'll mess around with it for a bit.
Thanks for the help.
 
In case you ever come back to programming, here's for comparison
 
Oh I got it, had to reference the value at the addr instead of the addr.
That moment when you're in a data structures class covering hashing and you forgot how to work properly with pointers :(
Anyways, thanks for the help guys.
 

« first day (98 days earlier)      last day (2751 days later) »