0

I'm trying to send a list of songnames to a client i built. Everything compiles fine, it even sends the first filename right. When the server begins to send the second filename it sends every filename as one. E.g:
First: Like the way.mp3
Second: Pump it up.mp3Billionaire.mp3...... it just continues like this.

I also print every filename with "cout", and there's everything fine.

CFileFind finder;
    CString myDirectory = "E:\\Users\\****\\Music\\Musiklk\\";
    BOOL finding = finder.FindFile (myDirectory + CString ("\\*.mp3"));
    while (finding)
    {
        finding = finder.FindNextFile();
        CString fname = finder.GetFileName();
        char songname[200] = "";
        strncpy((char *) songname, (LPCTSTR) fname, sizeof(songname));
        send(client,songname,strlen(songname),0);
        cout << songname << endl;
    }
    finder.Close ();

BTW: I'm still learning C++....

2
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by haggard433
0

If

cout << songname << endl;

works as intended and prints the song names on each individual line, then the send function is missing the endl. Is send in a library or a function you created? I'm not familiar with it if it's from a library.

0

The send() function is there to send the string to the socket and the socket sends it to the client. The weird thing is that it seems that the loop puts everything in the string at the same time... 'Cause when i use 2 different strings and send both of them, everything works fine..

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.