Seite 291 von 340 ErsteErste ... 191 241 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 ... LetzteLetzte
Zeige Ergebnis 8.701 bis 8.730 von 10174

C/C++ Programming Help Thread

This is a discussion on C/C++ Programming Help Thread within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; woa, woa man WALL of text...

  
  1. #8701
    QJ Gamer Gold
    Points: 17.453, Level: 84
    Level completed: 21%, Points required for next Level: 397
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    everywhere
    Beiträge
    3.526
    Points
    17.453
    Level
    84
    Downloads
    1
    Uploads
    0

    Standard

    woa, woa man WALL of text


    1. Failed....again...
    2. http://slicer.gibbocool.com/ stay updated on all my projects
    3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been

  2. #8702
    Developer
    Points: 7.577, Level: 58
    Level completed: 14%, Points required for next Level: 173
    Overall activity: 0%

    Registriert seit
    Mar 2006
    Beiträge
    1.026
    Points
    7.577
    Level
    58
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Khatharr Beitrag anzeigen
    Is this simply reporting the amount of memory not
    allocated to my heap and stack?
    Pretty much yeah.

    If you want an accurate (ish) way of checking how much memory you have free within the heap, malloc in big chunks until it fails :)

    I wouldn't worry about memory footprint yet. Get it working - then optimise.

    Check out my homebrew & C tutorials at http://insomniac.0x89.org/
    Coder formerly known as Insomniac197

    tshirtz: what is irshell ??
    Atarian_: it's where people who work for the IRS go when they die

  3. #8703
    Points: 2.658, Level: 31
    Level completed: 39%, Points required for next Level: 92
    Overall activity: 0%

    Registriert seit
    Apr 2008
    Beiträge
    47
    Points
    2.658
    Level
    31
    Downloads
    0
    Uploads
    0

    Standard

    Hmm... I guess I could just malloc for the netplayers in such a way that if it fails it can run the cleanup stuff and free idle players. I'll play around with it.

    Thanks again.

  4. #8704
    Lua guy
    Points: 11.690, Level: 71
    Level completed: 10%, Points required for next Level: 360
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Ort
    Wales, cardiff
    Beiträge
    1.442
    Points
    11.690
    Level
    71
    My Mood
    Blah
    Downloads
    0
    Uploads
    0

    Standard

    Ummh...... I was wondering, is there an pre-compiled cygwin release, by this i mean like all the files like libmad,
    Or should i download the packages from the internet, then
    Code:
    cd C:/cygwin
    make
    make install
    Then would i run an installer that it made, if it makes one (sorry i dont know cygwin very well yet or C for that matter)?
    Would i work?

  5. #8705
    words are stones in my <3
    Points: 35.274, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Spokane
    Beiträge
    5.008
    Points
    35.274
    Level
    100
    My Mood
    Lonely
    Downloads
    1
    Uploads
    0

    Standard

    There is a script on the SVN (in the psptoolchain folder i believe) that will automatically download and install all the commonly used libraries, if not a large majority of them (libmad, libmikmod, pspgl, etc.).

    I forgot the script name ,but take a look in the psptoolchain folder or google.

    ...at what speed must I live.. to be able to see you again?...

    Projects

    You can support my Open World 3D RPG for PSP by voting for it here


  6. #8706
    Lua guy
    Points: 11.690, Level: 71
    Level completed: 10%, Points required for next Level: 360
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Ort
    Wales, cardiff
    Beiträge
    1.442
    Points
    11.690
    Level
    71
    My Mood
    Blah
    Downloads
    0
    Uploads
    0

    Standard

    ok, thanks
    Last question: What are the 5 most common libraries, and what to they do?

  7. #8707
    Developer
    Points: 7.577, Level: 58
    Level completed: 14%, Points required for next Level: 173
    Overall activity: 0%

    Registriert seit
    Mar 2006
    Beiträge
    1.026
    Points
    7.577
    Level
    58
    Downloads
    0
    Uploads
    0

    Standard

    The script is psplibraries.

    I wouldn't worry about 3rd party libraries yet. When you need them, you'll know how to get them.

    Check out my homebrew & C tutorials at http://insomniac.0x89.org/
    Coder formerly known as Insomniac197

    tshirtz: what is irshell ??
    Atarian_: it's where people who work for the IRS go when they die

  8. #8708
    No longer a community member.
    Points: 46.662, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Dec 2005
    Beiträge
    22
    Points
    46.662
    Level
    100
    Downloads
    0
    Uploads
    0

    Standard

    SDL is confusing me again. Basically, I just want to make a simple image class. This class will load an image in the constructor, and draw it to the screen with x and y coordinates when asked. This should be pretty straightforward.

    I have most of the code working. I can load images and free them. However, the problem comes when I try to put the images into a vector. Currently, the code I have gives a Segmentation Fault. And yes, the images do exist. I think this is because I don't have a copy constructor. I have tried to make a few, but I don't think that I am doing this right. Could somebody shed some light on my problem?

    The code is below. Yes, I know, it is basic (just the Image class and a main loop). I'm just trying to get this working. Oh, and sorry about the indenting. It looks fine in gedit or code::blocks, but for some reason the forums think that organization is overrated.

    Spoiler for Code:
    Code:
    #include <SDL/SDL.h>
    #include <SDL/SDL_image.h>
    #include <vector>
    #include <string>
    
    SDL_Event event;
    SDL_Surface *screen;
    
    class Image
    {
        public:
            Image(const std::string &filename, int r = 255, int g = 0, int b = 255);
            ~Image();
    
            int getW() const;
            int getH() const;
            void draw(int x, int y, bool centerx = false, bool centery = false) const;
    
        private:
            bool isValid() const;
    
            SDL_Surface *m_pImage;
    };
    
    Image::Image(const std::string &filename, int r, int g, int b) : m_pImage(NULL)
    {
        m_pImage = IMG_Load(filename.c_str());
    
        if (isValid())
        {
            m_pImage = SDL_DisplayFormat(m_pImage);
            if (isValid())
                SDL_SetColorKey(m_pImage, SDL_SRCCOLORKEY, SDL_MapRGB(m_pImage->format, r, g, b));
        }
    }
    
    Image::~Image()
    {
        if(isValid())
    	{
    		SDL_FreeSurface(m_pImage);
    	}
    }
    
    int Image::getW() const
    {
        return m_pImage->w;
    }
    
    int Image::getH() const
    {
        return m_pImage->h;
    }
    
    void Image::draw(int x, int y, bool centerx, bool centery) const
    {
        SDL_Rect coords;
        coords.x = x - centerx * getW() / 2;
        coords.y = y - centery * getH() / 2;
        SDL_BlitSurface(m_pImage, NULL, screen, &coords);
    }
    
    bool Image::isValid() const
    {
        return m_pImage != NULL;
    }
    
    int main (int argc, char *argv[])
    {
    	SDL_Init(SDL_INIT_VIDEO);
        atexit(SDL_Quit);
        screen = SDL_SetVideoMode(640, 480, 32, SDL_HWSURFACE|SDL_DOUBLEBUF);
    
    	std::vector<Image> imagelist;
    	imagelist.push_back(Image("number1.png"));
    	
    	bool done = false;
    	while (!done)
    	{
    		while (SDL_PollEvent(&event))
            {
                switch (event.type)
                {
                    case SDL_QUIT: done = true; break;
                    case SDL_KEYDOWN: if (event.key.keysym.sym == SDLK_ESCAPE) done = true; break;
                }
            }
    	
    		SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 255, 255, 255));        
    		
    		for (int i = 0; i < imagelist.size(); ++i)
    		{
    			imagelist[i].draw(100*i, 0);
    		}
    
            SDL_Flip(screen);
    	}
    	
    	return 0;
    }


    EDIT: I love how as soon as I post, a proper answer is revealed. Looking in the SDL docs, here's how to copy surfaces:
    Code:
      SDL_Surface *Srfc1, *Srfc2;
      Srfc1= IMG_Load("foo.png");
      Srfc2= Srfc1;
      Srfc2->refcount++;
      ..
      SDL_FreeSurface(Srfc1);
      SDL_FreeSurface(Srfc2);
    I just wasn't doing the refcount++ part. Therefore, if anybody is wondering, the copy constructor (in my case) is as follows:
    Code:
    Image::Image(const Image &oldImage)
    {
    	m_pImage = oldImage.m_pImage;
    	m_pImage->refcount++;
    }
    Geändert von Hardrive (06-22-2008 um 04:40 PM Uhr) Grund: Posted too soon

  9. #8709
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    You probably would want to implement the assignment operator as well.

    An alternative solution is to use a vector of pointer to images:
    Code:
    std::vector<Image*> imagelist;
    And new/delete as you push and pop.

    Or even better, use smart pointers:
    http://www.boost.org/doc/libs/1_35_0...shared_ptr.htm
    Code:
    std::vector< boost::shared_ptr<Image> > imagelist;
    imagelist.push_back(new Image("number1.png"));
    And the Images are destroyed when they are removed from the vector (unless you are holding another reference somewhere else).

  10. #8710
    No longer a community member.
    Points: 46.662, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Dec 2005
    Beiträge
    22
    Points
    46.662
    Level
    100
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von yaustar Beitrag anzeigen
    You probably would want to implement the assignment operator as well.

    An alternative solution is to use a vector of pointer to images:
    Code:
    std::vector<Image*> imagelist;
    And new/delete as you push and pop.

    Or even better, use smart pointers:
    http://www.boost.org/doc/libs/1_35_0...shared_ptr.htm
    Code:
    std::vector< boost::shared_ptr<Image> > imagelist;
    imagelist.push_back(new Image("number1.png"));
    And the Images are destroyed when they are removed from the vector (unless you are holding another reference somewhere else).
    Of course, you have to come in here and find a better way to do something...

    Anyways, will the boost libraries work on the PSP?

  11. #8711
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Hardrive Beitrag anzeigen
    Of course, you have to come in here and find a better way to do something...

    Anyways, will the boost libraries work on the PSP?
    Should do. Most of the 'libraries' you just have to include the header file (hpp) as they are templates. You can get away with just copying the shared_ptr file and #including it.

  12. #8712
    Points: 2.658, Level: 31
    Level completed: 39%, Points required for next Level: 92
    Overall activity: 0%

    Registriert seit
    Apr 2008
    Beiträge
    47
    Points
    2.658
    Level
    31
    Downloads
    0
    Uploads
    0

    Standard

    Okay, I've been busy. Three quick questions. I'll try to be brief.

    1) Is there anything in the standard library that supports regular expressions, or else a popular lib for doing so? sscanf isn't cutting it. (I can try to use the Ruby API if no.)

    2) I've been using read() to get data from my sockets, but it seems to leave a '\n' on the buffer when I use it, so I'm being forced to do an additional read() of single char width every time. Is this normal? I suspect I should be using recv(), but I don't know which flags to feed it.

    3) From what I understand variables declared in a function are deallocated when the function terminates (unless returned). Is this also true of memory allocated by pointers? IOW, if I declare 'char my_str[32]' in a function do both the pointer and the chars get deallocated when the function ends?

    Thanks for any advice. Sorry to ask so many questions.

  13. #8713
    QJ Gamer Bronze
    Points: 6.359, Level: 52
    Level completed: 5%, Points required for next Level: 191
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    france
    Beiträge
    170
    Points
    6.359
    Level
    52
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Khatharr Beitrag anzeigen
    From what I understand variables declared in a function are deallocated when the function terminates (unless returned). Is this also true of memory allocated by pointers? IOW, if I declare 'char my_str[32]' in a function do both the pointer and the chars get deallocated when the function ends?
    char my_str[32] is not a pointer, char *my_str=new char[32] is a pointer, it deallocates automatically when out of scope, but for the chars you'll need a delete[] my_str;
    You should read some tutorials on pointers it's important to understand.
    Try my latest game (iOS):


  14. #8714
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Khatharr Beitrag anzeigen
    Okay, I've been busy. Three quick questions. I'll try to be brief.

    1) Is there anything in the standard library that supports regular expressions, or else a popular lib for doing so? sscanf isn't cutting it. (I can try to use the Ruby API if no.)
    Boost Regex does: http://www.boost.org/doc/libs/1_35_0...tml/index.html

    I haven't used it before so I can't advise how to get it running.

  15. #8715
    Points: 2.658, Level: 31
    Level completed: 39%, Points required for next Level: 92
    Overall activity: 0%

    Registriert seit
    Apr 2008
    Beiträge
    47
    Points
    2.658
    Level
    31
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von daaa57150 Beitrag anzeigen
    char my_str[32] is not a pointer, char *my_str=new char[32] is a pointer, it deallocates automatically when out of scope, but for the chars you'll need a delete[] my_str;
    You should read some tutorials on pointers it's important to understand.
    If I say 'char my_str[32];' and then refer to my_str it acts as a pointer, no? Functions that accept 'char *' as args will accept 'my_str'. You're saying that if I have a function that has that line in it I should say 'delete[] my_str;' in order to deallocate the chars themselves?

    Yaustar, thanks. I'll take a look.
    ---------------------------------------------------------
    Found a reference. Both the pointer and the array are deallocated (actually, removed from the stack) when they lose scope. You only have to use 'delete' if you created something with 'new'.

    Still curious about my socket behavior, though.
    Geändert von Khatharr (06-25-2008 um 11:44 AM Uhr)

  16. #8716
    QJ Gamer Bronze
    Points: 5.402, Level: 47
    Level completed: 26%, Points required for next Level: 148
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Beiträge
    468
    Points
    5.402
    Level
    47
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Khatharr Beitrag anzeigen

    3) From what I understand variables declared in a function are deallocated when the function terminates (unless returned). Is this also true of memory allocated by pointers? IOW, if I declare 'char my_str[32]' in a function do both the pointer and the chars get deallocated when the function ends?

    Thanks for any advice. Sorry to ask so many questions.
    yeah, variables defined within a function are local to that function and they will be deallocated when the function terminates. If you need a variable that is defined within a function to retain its value between function calls declare it static.

  17. #8717
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    If I say 'char my_str[32];' and then refer to my_str it acts as a pointer, no?
    No. It can be degraded to a char * but to the compiler, it is different.

    Try this code:
    Code:
    char buffer1[128] = "Hello World";
    char * buffer2 = "Hello World";
    
    int sizeOfBuffer1 = sizeof(buffer1);
    int sizeOfBuffer2 = sizeof(buffer2);
    Take a look at the the values of sizeOfBuffer1 and sizeOfBuffer2. Conceptually, the difference between a char * and char buffer is important.

  18. #8718
    Points: 2.658, Level: 31
    Level completed: 39%, Points required for next Level: 92
    Overall activity: 0%

    Registriert seit
    Apr 2008
    Beiträge
    47
    Points
    2.658
    Level
    31
    Downloads
    0
    Uploads
    0

    Standard

    I understand what you're saying, I'm just not expressing myself correctly. I view the line:

    char mystr[3];

    as allocating 3 chars and also allocating a pointer, such that mystr is sort of a 'pointer/char/char/char' which holds both the pointer to the array and the information about the array. I was concerned that perhaps the pointer part would be discarded but the array part wouldn't be, but I found some documentation that explains the handling and it's all good. I was just concerned because I was looking at some example code and the person who wrote it was using malloc in a private function and then freeing the data at the end of the function with no use of realloc/calloc or anything. I didn't/don't understand why he did that. Thanks for the clarification, though.

    Am I alone on this socket-reading problem?

  19. #8719
    Developer
    Points: 3.206, Level: 35
    Level completed: 4%, Points required for next Level: 144
    Overall activity: 0%

    Registriert seit
    Aug 2007
    Beiträge
    74
    Points
    3.206
    Level
    35
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von yaustar Beitrag anzeigen
    No. It can be degraded to a char * but to the compiler, it is different.

    Try this code:
    Code:
    char buffer1[128] = "Hello World";
    char * buffer2 = "Hello World";
    
    int sizeOfBuffer1 = sizeof(buffer1);
    int sizeOfBuffer2 = sizeof(buffer2);
    Take a look at the the values of sizeOfBuffer1 and sizeOfBuffer2. Conceptually, the difference between a char * and char buffer is important.
    Another important distinction is that buffer1 == &buffer1 whereas buffer2 != &buffer2. An array does not explicitly store an address in memory, that is, there is no value for buffer1 that is stored in memory (buffer1 will take the address of the first element of the array). The pointer on the other hand explicitly stores an address (the address at which will be a variable of type char). So the "Hello World" of buffer1 is stored on the stack, however the "Hello World" of buffer2 is NOT stored on the stack (just the address of the "Hello World" string).

    This is an important point to remember.

    Zitat Zitat von Khatharr Beitrag anzeigen
    I understand what you're saying, I'm just not expressing myself correctly. I view the line:

    char mystr[3];

    as allocating 3 chars and also allocating a pointer, such that mystr is sort of a 'pointer/char/char/char' which holds both the pointer to the array and the information about the array.
    No it doesnt. It doesnt hold a pointer to the array, mystr really is just 'char/char/char'. The 'pointer' you speak of is just the address of the start of the array, no where in memory will you find this address explicitly stored.
    PSP PRX LibDoc's Lives On!
    http://silverspring.lan.st/

    My new home:
    http://my.malloc.us/silverspring/

  20. #8720
    Points: 2.658, Level: 31
    Level completed: 39%, Points required for next Level: 92
    Overall activity: 0%

    Registriert seit
    Apr 2008
    Beiträge
    47
    Points
    2.658
    Level
    31
    Downloads
    0
    Uploads
    0

    Standard

    If that's the case then why doesn't mystr refer to the first char? Are arrays just handled as a distinct type from their non-array equivalents?

  21. #8721
    Developer
    Points: 3.206, Level: 35
    Level completed: 4%, Points required for next Level: 144
    Overall activity: 0%

    Registriert seit
    Aug 2007
    Beiträge
    74
    Points
    3.206
    Level
    35
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Khatharr Beitrag anzeigen
    If that's the case then why doesn't mystr refer to the first char? Are arrays just handled as a distinct type from their non-array equivalents?
    mystr refers to the address of the first char (mystr[0] being the first char), ie. mystr is equivalent to &mystr[0], there isnt a memory location that holds the value of mystr itself. However, mystr as a pointer is an actual value in memory that explicitly stores an address.
    Geändert von SilverSpring (06-26-2008 um 09:22 PM Uhr)
    PSP PRX LibDoc's Lives On!
    http://silverspring.lan.st/

    My new home:
    http://my.malloc.us/silverspring/

  22. #8722
    Points: 2.658, Level: 31
    Level completed: 39%, Points required for next Level: 92
    Overall activity: 0%

    Registriert seit
    Apr 2008
    Beiträge
    47
    Points
    2.658
    Level
    31
    Downloads
    0
    Uploads
    0

    Standard

    Okay, this is too much conversation about something I already know how to use. Thank you all for the clarifications. Does anybody have even the most remove notion about my problem using read() on sockets?

  23. #8723
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Khatharr Beitrag anzeigen
    Okay, this is too much conversation about something I already know how to use. Thank you all for the clarifications. Does anybody have even the most remove notion about my problem using read() on sockets?
    For clarification, are you using this read function?
    http://www.cppreference.com/cppio/read.html

    Edit: Nevermind. Does this site help? http://www.pcs.cnu.edu/~dgame/socket...+/sockets.html

  24. #8724
    Points: 2.658, Level: 31
    Level completed: 39%, Points required for next Level: 92
    Overall activity: 0%

    Registriert seit
    Apr 2008
    Beiträge
    47
    Points
    2.658
    Level
    31
    Downloads
    0
    Uploads
    0

    Standard

    I found some info about the recv() flags and I'll test with recv() to see if it's having the same problem when I get home. Thank you for the link, but I'm only working in C, not C++ yet. I do already have a lot of experience working with sockets in Ruby and Lua and I can easily create, bind, connect and read/write to them. I just can't figure out where these random '\n' are coming from, so I'm trying to figure out if it's normal or if my PSP or perhaps my toolchain install are somehow tarded. If I have the same problem with recv() as I'm having with read() then I'll just have to set my socket reads up to discard any read that starts with '\n' maybe. Since there's no '\0' after the '\n' I'm ending up with things like this:

    server sends: "This is a string.\n\0"
    PSP reads: "This is a string.\n\0"
    PSP reads again: "\nhis is a string.\n\0"

    The server's using Ruby's 'puts()', but I had the same problem with data from an incoming telnet socket. Like I mentioned earlier I'd just discard every other read, but about 1 in 100 times it doesn't do it, so I'd be risking data loss.

    Acketh... Sorry to WoT again.
    ----------------------------------------------------
    Edit: I guess the quickest way to find out if something's up would be to ask someone to compile and run the tester source I got from BigBlack's post here. If telnetting in and typing results in double characters on the PSP (ie "test" => "tteesstt") then this isn't a unique problem to my system.
    Geändert von Khatharr (06-27-2008 um 02:31 PM Uhr)

  25. #8725
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    Have you tried making a simple PC client to check what you are receiving from the server? What you are actually sending may not match up with what you think you are sending.

  26. #8726
    Points: 2.658, Level: 31
    Level completed: 39%, Points required for next Level: 92
    Overall activity: 0%

    Registriert seit
    Apr 2008
    Beiträge
    47
    Points
    2.658
    Level
    31
    Downloads
    0
    Uploads
    0

    Standard

    This particular server is well known to me as it's the server that I started to learn socket manipulation with several years ago. It's only about 20 lines long and sends one of three strings, each of them being enclosed in html-like tags, such as "<chat>actual-data</chat>" and they are sent using Socket.puts(), which appends a '\n' to the end of the string. AFAIK Ruby always silently null-terminates its strings. I've never experienced any similar problem with this server in the past, though it is somewhat archaic in other ways.

    However, just for the sake of thoroughness, I'll write a simple console app for my PC to test data from the server and see if it experiences the same problem. I don't suspect that this is the case because I'm getting the same strange behavior when I use telnet to connect to the PSP as a server. I'm about to go home for the day, so I'll test using recv() and if that doesn't get it then I'll whip out a quick PC console app to see just exactly what bytes are being sent.

    Thank you for your patience and support.
    ----------------------------------------------
    Update:
    Wow, hurray for yaustar and for thoroughness. The server is indeed sending "string\0\n", which I don't recall it doing in the past. I did, however, recently upgrade my Ruby install, so maybe it's a bug in the new version, or maybe for some bizzare reason I never caught it in over 3 years of working with this server. I also figured out the reason that it occasionally didn't occur. Seems that if more than one message is waiting on the stream then it would deliver the next message on the next read with the \n prepended to it, so I didn't catch it as a single character length '\n'. Now that I understand this behavioral oddity, though, I've easily coded around it and I'm catching all my data correctly now. Thanks, yau. About the telnet thing, I can't figure out why I thought telnet was doing that. When I tested it last night it worked fine. Maybe I was looking at the telnet screen where the echoes were added to the local characters and I thought it was screwing up. I suppose I should take this as a sign that coding should end at midnight rather than at 6 AM so I can see what the hell I'm doing.

    Thanks again to everyone.
    Geändert von Khatharr (06-28-2008 um 11:05 AM Uhr)

  27. #8727
    QJ Gamer Bronze
    Points: 8.045, Level: 60
    Level completed: 48%, Points required for next Level: 105
    Overall activity: 0%

    Registriert seit
    Aug 2007
    Ort
    Australia
    Beiträge
    659
    Points
    8.045
    Level
    60
    Downloads
    0
    Uploads
    0

    Standard

    Quick question, how can i remove digits from a float. For example if i have:
    Code:
    float myFloat = 1.234;
    how can i cut it down to just
    Code:
    1.2
    ? Thanks

  28. #8728
    It's good to be free...
    Points: 10.420, Level: 67
    Level completed: 93%, Points required for next Level: 30
    Overall activity: 0%

    Registriert seit
    Feb 2007
    Beiträge
    2.440
    Points
    10.420
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    roundf(theFloat*10.0f)/10.0f

    :/
    pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ

  29. #8729
    QJ Gamer Bronze
    Points: 8.045, Level: 60
    Level completed: 48%, Points required for next Level: 105
    Overall activity: 0%

    Registriert seit
    Aug 2007
    Ort
    Australia
    Beiträge
    659
    Points
    8.045
    Level
    60
    Downloads
    0
    Uploads
    0

    Standard

    thanks man

  30. #8730
    Developer
    Points: 6.074, Level: 50
    Level completed: 62%, Points required for next Level: 76
    Overall activity: 0%

    Registriert seit
    Sep 2005
    Beiträge
    270
    Points
    6.074
    Level
    50
    Downloads
    0
    Uploads
    0

    Standard

    hello, i am having problems getting the cygwin thing set up. i type in "make" in the shell and it says "nothing can be done for all."


 

Tags for this Thread

Forumregeln

  • Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
  • Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
  • Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
  • Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.
  •  





Alle Zeitangaben in WEZ -8. Es ist jetzt 09:27 PM Uhr.

Use of this Web site constitutes acceptance of the TERMS & CONDITIONS and PRIVACY POLICY
Copyright © , Caputo Media, LLC. All Rights Reserved. Cluster .