[QUOTE=FerrisWheel;21934455]I'm attempting to write a simple file transfer (over TCP sockets) application. But the file being written isn't the same. The written file is the same length, but is different.
[url=http://pastebin.com/axVqVfpJ]pastebin[/url]
Any help on why what I send is not what I receive and write?[/QUOTE]
Use memcpy, not strcpy. Also, you're leaking a lot, you should delete those heap allocated buffers. However, there's no reason to use dynamic memory there because the buffer-size is static (or guaranteed to be less than the static size), just use a single buffer like this:
[cpp]
static char bytes[512];
[/cpp]
And line 43 won't work without compiler extensions (C++ does not support dynamic stack-allocated arrays), in case you were trying for portable code.
[QUOTE=blankthemuffin;21934511]-snip-[/QUOTE]
Is this your idea of not being on IRC to improve productivity?
[QUOTE=blankthemuffin;21934657]No I'm just on for 5 minutes, needed to send some emails and stuff. Leaving again now.[/QUOTE]
... you better not be trying to escape. I locked all three locks before leaving today, so don't get any funny ideas
[QUOTE=jA_cOp;21934591]Is this your idea of not being on IRC to improve productivity?[/QUOTE]
No I'm just on for 5 minutes, needed to send some emails and stuff. Leaving again now.
[QUOTE=jA_cOp;21934591]Use memcpy, not strcpy. Also, you're leaking a lot, you should delete those heap allocated buffers. However, there's no reason to use dynamic memory there because the buffer-size is static (or guaranteed to be less than the static size), just use a single buffer like this:
[cpp]
static char bytes[512];
[/cpp]
And line 43 won't work without compiler extensions (C++ does not support dynamic stack-allocated arrays), in case you were trying for portable code.
[/QUOTE]
Thanks, changing strcpy to memcpy was the problem. I'll fix up the memory leaks and dynamic arrays just now.
[QUOTE=arienh4;21920736]There's no difference between LINQ to Objects/SQL/whatever.
The only difference with LINQ to SQL is that the queries are translated to SQL statements at compile-time.[/QUOTE]
By LINQ to Objects/SQL/whatever, I meant this stuff:
[code]
var results = from c in SomeCollection
where c.SomeProperty < someValue * 2
select new {c.SomeProperty, c.OtherProperty};
[/code]
I was probably using the wrong terminology
[QUOTE=FerrisWheel;21934455]I'm attempting to write a simple file transfer (over TCP sockets) application. But the file being written isn't the same. The written file is the same length, but is different.
[url=http://pastebin.com/axVqVfpJ]pastebin[/url]
Any help on why what I send is not what I receive and write?[/QUOTE]
Just FYI when sending files over a remote network (and not local) you should always buffer your connection first. This prevents packets from being lost over the network connection.
Does anybody have an idea if I should use C++ strings in my C++ engine or C strings (const char*)?
[QUOTE=CPPNOOB;21939236]Does anybody have an idea if I should use C++ strings in my C++ engine or C strings (const char*)?[/QUOTE]
I'm no C++ coder but using C++ strings in a C++ engine seems about right.
Wouldn't use VB strings in a C# engine would you? (I probably have no idea what I'm talking about though, feel free to rate me dumb)
[editline]11:47AM[/editline]
[QUOTE=Dlaor;21900466]-code-
This is my Entity class, used for the player in my MC ripoff (made in Processing). The collision is partly working, but still very glitchy. Would any physics-guru help me out here?[/QUOTE]
Well when you're moving, and you have the velocity of your player, and if they collide with an object, multiply their velocity by -1 which will reverse the velocity.
[QUOTE=Poodle;21939269]I'm no C++ coder but using C++ strings in a C++ engine seems about right.[/QUOTE]
You're right.
That means eventually at low level I have to convert them to normal strings. To pass them to C functions (yes, I do the raw C functions, it's an engine, STFU)
[QUOTE=turb_;21937011]By LINQ to Objects/SQL/whatever, I meant this stuff:
[code]
var results = from c in SomeCollection
where c.SomeProperty < someValue * 2
select new {c.SomeProperty, c.OtherProperty};
[/code]
I was probably using the wrong terminology[/QUOTE]
That's all turned into SomeCollection.Select(c => ) etc. There's no difference.
[QUOTE=CPPNOOB;21939547]That means eventually at low level I have to convert them to normal strings. To pass them to C functions (yes, I do the raw C functions, it's an engine, STFU)[/QUOTE]
There is no converting, the c_str() method of std::string just returns a const pointer to the data.
And really you'll be using strings much more in your own code than you will pass them to c apis.
[QUOTE=arienh4;21939643]That's all turned into SomeCollection.Select(c => ) etc. There's no difference.[/QUOTE]
I know, what I meant is I didn't want to confuse him with the alternate syntax
[QUOTE=blankthemuffin;21939647]There is no converting, the c_str() method of std::string just returns a const pointer to the data.
And really you'll be using strings much more in your own code than you will pass them to c apis.[/QUOTE]
Ohhh. So there's.. Strings are just const chars but easier to handle?
[QUOTE=CPPNOOB;21939812]Ohhh. So there's.. Strings are just const chars but easier to handle?[/QUOTE]
Errr, in a super simplistic way. And they're not const, they're mutable. But the c_str method exposes a const pointer to that data.
[QUOTE=Poodle;21938836]Just FYI when sending files over a remote network (and not local) you should always buffer your connection first. This prevents packets from being lost over the network connection.[/QUOTE]
TCP does the acknowledgement and retransmission stuff necessary to handle packet loss, so that applications don't have to concern themselves with it. (And applications can't prevent packet loss anyway; the best that one can do is handle it gracefully when it occurs, which is what TCP does.)
Say I'm using FileSystemWatcher monitoring a folder, it's good because it fires after something is created letting me grab the NTFS unique ID and handle stuff via that but I'm wondering if there is any way to make FileSystemWatcher grab the ID before it's deleted? at the minute it's already gone by the time the watcher is fired.
[QUOTE=turb_;21939685]I know, what I meant is I didn't want to confuse him with the alternate syntax[/QUOTE]
Resharper can convert them anyway.
[QUOTE=blankthemuffin;21934511]It would help if you actually told us the problem.[/QUOTE]
The problem is that, the "alive" variable of the bullet should changes to false when the bullet leaves the screen, but apparently changes too false immediatly after shooting it, making it dissapear before starting too fly.
Need some help with RSA.
-Is it easy to use ssh style keys with RSACryptoServiceProvider? Or should I just use bouncycastle?
-In the ssh style keys, how is it formatted? Like what part is the "q" and what part is the "r"?
Edit:
Okay, looked at the raw data. Seems to just be bignums. But what is what? I saved the private key from puttygen and it has 1 0x80 sized bignum which I know is the key but then it is followed by 3 0x41 sized bignums.
[QUOTE=Jimbomcb;21940665]Say I'm using FileSystemWatcher monitoring a folder, it's good because it fires after something is created letting me grab the NTFS unique ID and handle stuff via that but I'm wondering if there is any way to make FileSystemWatcher grab the ID before it's deleted? at the minute it's already gone by the time the watcher is fired.[/QUOTE]
You can either open an exclusive lock on the files, change the ACL on the files to disallow deletion, or do something low level. You can't with FileSystemWatcher
Also, how did you get FSW to work? It never works for me
I'm coding a 2D game engine in Java and OpenGL. Right now I'm working on it's sound system, and my current plans are to have it play each sound on its own thread, so that there's no limit on the number of sounds you can have playing at once. Is this good practice, or should I rethink how this is going to work?
[QUOTE=Smashmaster;21949914]I'm coding a 2D game engine in Java and OpenGL. Right now I'm working on it's sound system, and my current plans are to have it play each sound on its own thread, so that there's no limit on the number of sounds you can have playing at once. Is this good practice, or should I rethink how this is going to work?[/QUOTE]
Rethink how it's going to work.
[QUOTE=blankthemuffin;21950220]Rethink how it's going to work.[/QUOTE]
Why
[QUOTE=raccoon12;21950283][code]1>Font.obj : error LNK2001: unresolved external symbol "public: __thiscall sf::Unicode::Text::Text(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0Text@Unicode@sf@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)[/code]
-snip-
Why[/QUOTE]
Did you link against the sfml-graphics module properly?
Also, the "TFont::" prefix inside a member function definition isn't necessary unless referring to static variables or functions of that class.
I also wonder why your font class has a text field.
[QUOTE=jA_cOp;21950465]Did you link against the sfml-graphics module properly?
Also, the "TFont::" prefix inside a member function definition isn't necessary unless referring to static variables or functions of that class.
I also wonder why your font class has a text field.[/QUOTE]
Yes
Thanks, didn't know that, still learning c++
m_Text? Basically SetText takes the std::string text and sets m_Text to that and then I can App.Draw(fonttest.m_Text), although I'm guessing it's probably not a good practice? I don't know
Well, a font usually just is the 'design' for a text, but not the text itself.
It would make sense to have a text-class, that has a Font-member and a string you can modify.
[QUOTE=raccoon12;21950283][code]1>Font.obj : error LNK2001: unresolved external symbol "public: __thiscall sf::Unicode::Text::Text(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0Text@Unicode@sf@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)[/code]TextFont.h
#include <sfml/Graphics.hpp>
#include <string>
class TFont
{
public:
void SetText(std::string text, int size);
sf::Font m_Font;
sf::String m_Text;
};
TextFont.cpp
#include "TextFont.h"
void TFont::SetText(std::string text, int size)
{
TFont::m_Text.SetText(text);
TFont::m_Text.SetFont(m_Font);
TFont::m_Text.SetSize(size);
}
Why[/QUOTE]
Are you using SFML 2?
1.6
[QUOTE=Poodle;21938836]Just FYI when sending files over a remote network (and not local) you should always buffer your connection first. This prevents packets from being lost over the network connection.[/QUOTE]
Can you explain what you mean by this? I'm new to sockets.
Sorry, you need to Log In to post a reply to this thread.