Seite 39 von 340 ErsteErste ... 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 89 139 ... LetzteLetzte
Zeige Ergebnis 1.141 bis 1.170 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; Zitat von psphacker12. How can I fix that? add a ; to the end of the last line....

  
  1. #1141
    Developer
    Points: 5.359, Level: 47
    Level completed: 5%, Points required for next Level: 191
    Overall activity: 0%

    Registriert seit
    Feb 2006
    Ort
    Norway
    Beiträge
    384
    Points
    5.359
    Level
    47
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von psphacker12.
    How can I fix that?


    add a ; to the end of the last line.




  2. #1142
    likes kittens....awww....
    Points: 6.975, Level: 55
    Level completed: 13%, Points required for next Level: 175
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Detroit
    Beiträge
    628
    Points
    6.975
    Level
    55
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von head_54us
    Great idea, quote the entire post for one small part of it (-_-;)

    Code:
    int nums() {
         if (rn0 != (NULL) && rn1 != (NULL) && rn2 != (NULL)) {
           rn0=0
           rn1=0
           rn2=0
         }
    Code:
    int nums() {
       int rn0=0;
       int rn1=0;
       int rn2=0;
       SceCtrlData pad;
    Here is another tip, buy this book:
    The C programming Language or this one Beginning C++ Game Programming or at LEAST read this online one: Thinking like a computer scientist [C++]
    I've been looking over "Thinking like a computer scientist [C++]" and I was wondering should I use cout<< or printf??

  3. #1143
    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

    Use printf. Getting the STL library to work with the PSP compiler is a bit of work.

  4. #1144
    likes kittens....awww....
    Points: 6.975, Level: 55
    Level completed: 13%, Points required for next Level: 175
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Detroit
    Beiträge
    628
    Points
    6.975
    Level
    55
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von head_54us
    Great idea, quote the entire post for one small part of it (-_-;)

    Code:
    int nums() {
         if (rn0 != (NULL) && rn1 != (NULL) && rn2 != (NULL)) {
           rn0=0
           rn1=0
           rn2=0
         }
    Code:
    int nums() {
       int rn0=0;
       int rn1=0;
       int rn2=0;
       SceCtrlData pad;
    Here is another tip, buy this book:
    The C programming Language or this one Beginning C++ Game Programming or at LEAST read this online one: Thinking like a computer scientist [C++]
    couldnt i just do this??
    Code:
    int nums() {
      funcs();
    or would that give me an error?
    im trying it now. :)

  5. #1145
    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 are just calling the function. It will still give the same error. Read about variable scope.

  6. #1146
    QJ Gamer Blue
    Points: 4.511, Level: 42
    Level completed: 81%, Points required for next Level: 39
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Germany
    Beiträge
    216
    Points
    4.511
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von head_54us
    GuitarGod1134:

    This is because the buf that was in the function was created locally on the stack and the function returns a pointer to it. However, after the pointer assignment to buffer, it is removed from the stack since it is no longer in scope and now pointer is pointing to garbarge. A better method would be to do:

    [ code ]
    That works, thank you!

  7. #1147
    sceKernelExitGame();
    Points: 19.955, Level: 89
    Level completed: 21%, Points required for next Level: 395
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Ort
    New York
    Beiträge
    3.126
    Points
    19.955
    Level
    89
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von head_54us
    Great idea, quote the entire post for one small part of it (-_-;)

    Code:
    int nums() {
         if (rn0 != (NULL) && rn1 != (NULL) && rn2 != (NULL)) {
           rn0=0
           rn1=0
           rn2=0
         }
    Code:
    int nums() {
       int rn0=0;
       int rn1=0;
       int rn2=0;
       SceCtrlData pad;
    Here is another tip, buy this book:
    The C programming Language or this one Beginning C++ Game Programming or at LEAST read this online one: Thinking like a computer scientist [C++]
    I believe the fist book you mentioned can be read for free here: http://www.fis.cinvestav.mx/~jccoron...guageAnsiC.pdf

  8. #1148
    likes kittens....awww....
    Points: 6.975, Level: 55
    Level completed: 13%, Points required for next Level: 175
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Detroit
    Beiträge
    628
    Points
    6.975
    Level
    55
    Downloads
    0
    Uploads
    0

    Standard

    Code:
    #include <pspdisplay.h>
    #include <pspgu.h>
    #include <pspkernel.h>
    #include <pspctrl.h>
    #include <pspdebug.h>
    #include <stdlib.h>
    #include <stdio.h>
    #include <math.h>
    #include <time.h>
    #include <png.h>
    #include "graphics.h"
    #define printf pspDebugScreenPrintf
    #define dprint pspDebugScreenPrintf
    #define true 1
    #define false !true
    #define bool int
    #define NULL 0
    
    PSP_MODULE_INFO("???", 0, 1, 1);
    
    /* Standard callbacks */
    int exit_callback(int arg1, int arg2, void *common) {
              sceKernelExitGame();
              return 0;
    }
    
    int CallbackThread(SceSize args, void *argp) {
              int cbid;
    
              cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
              sceKernelRegisterExitCallback(cbid);
    
              sceKernelSleepThreadCB();
    
              return 0;
    }
    
    int SetupCallbacks(void) {
              int thid = 0;
    
              thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
              if(thid >= 0) {
                        sceKernelStartThread(thid, 0, 0);
              }
    
              return thid;
    }
    
    int nums() {
         int rn0 = 0;
         int rn1 = 0;
         int rn2 = 0;
         bool status = 0;
         SceCtrlData pad;
         sceCtrlPeekBufferPositive(&pad, 1);
         srand(sceKernelLibcTime(NULL));
         if (pad.Buttons != 0){
              if(pad.Buttons && PSP_CTRL_CROSS) {
               rn0=rand()%1,3;
               rn1=rand()%1,3;
               rn2=rand()%1,3;
              }
         }
         if (rn0 == 1 && rn1 == 1 && rn2 == 1) {
              pspDebugScreenSetXY(0,2);
              pspDebugScreenSetBackColor(0x00FF0000);
              pspDebugScreenSetTextColor(0x00000000);
              pspDebugScreenPrintf("You won.\n");
              pspDebugScreenPrintf("Press 'X' to restart.\n");
              if(pad.Buttons & PSP_CTRL_CROSS) {
                nums();
              }
         }
         if (rn0 == 2 && rn1 == 2 && rn2 == 2) {
              pspDebugScreenSetXY(0,2);
              pspDebugScreenSetBackColor(0x00FF0000);
              pspDebugScreenSetTextColor(0x00000000);
              pspDebugScreenPrintf("You won.\n");
              pspDebugScreenPrintf("Press 'X' to restart.\n");
              if(pad.Buttons & PSP_CTRL_CROSS) {
                nums();
              }
         }
         if (rn0 == 3 && rn1 == 3 && rn2 ==3) {
              pspDebugScreenSetXY(0,2);
              pspDebugScreenSetBackColor(0x00FF0000);
              pspDebugScreenSetTextColor(0x00000000);
              pspDebugScreenPrintf("You won.\n");
              pspDebugScreenPrintf("Press 'X' to restart.\n");
              if(pad.Buttons & PSP_CTRL_CROSS) {
                nums();
              }
         }
         if(rn0 == 0 && rn1 == 0 && rn2 == 0) {
              pspDebugScreenSetXY(0,2);
              pspDebugScreenClear();
              pspDebugScreenSetBackColor(0x00FF0000);
              pspDebugScreenSetTextColor(0x00000000);
              pspDebugScreenPrintf("Press |`'~X~'`| to start\n");
              if(pad.Buttons && PSP_CTRL_CROSS) {
               pspDebugScreenSetXY(0,2);
               pspDebugScreenClear();
               pspDebugScreenSetBackColor(0x00FF0000);
               pspDebugScreenSetTextColor(0x00000000);
               rn0=rand()%1,3;
               rn1=rand()%1,3;
               rn2=rand()%1,3;
              }     }
    }
    int main(void) {
              /* main functions */
              pspDebugScreenInit();
              SetupCallbacks();
              while(true) {
                        /* while loop */
                        nums();
              }
    return 0;
    }
    when I press 'x' it doesnt update the info..

  9. #1149
    Points: 3.787, Level: 38
    Level completed: 92%, Points required for next Level: 13
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Beiträge
    10
    Points
    3.787
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    Hey, sup guys? well I need help.
    Im trying to change DevHook Launcher font with this guide: Release: FLIB Truetype font library in C
    And its always dont working If someone can send me the DevHook Launcher SDK WITH ANY OTHER FONT And tell me where im chaging it again I would be very happy.

  10. #1150
    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

    psp12: You have been told this many times:
    && - logical AND
    & - Bitwise AND.

    Bronx: That link looks VERY illegal.

  11. #1151
    Developer
    Points: 5.359, Level: 47
    Level completed: 5%, Points required for next Level: 191
    Overall activity: 0%

    Registriert seit
    Feb 2006
    Ort
    Norway
    Beiträge
    384
    Points
    5.359
    Level
    47
    Downloads
    0
    Uploads
    0

    Standard

    How can I change which folder cygwin starts in?

    for me it starts in 'home/my name'

    but I wan't it to start in 'home/myname' tried renaming the my name folder to myname and then changing the name of my xp user to myname instead of my name.
    but cygwin just created a new folder still.


  12. #1152
    Developer
    Points: 14.378, Level: 77
    Level completed: 82%, Points required for next Level: 72
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Ort
    Boston, MA
    Beiträge
    1.389
    Points
    14.378
    Level
    77
    Downloads
    0
    Uploads
    0

    Standard

    Hey,
    Anybody know if normal PC SDL is exactly the same as PSP SDL.
    If not, whats the difference?
    --Vaza

  13. #1153
    AKA Homer
    Points: 12.596, Level: 73
    Level completed: 37%, Points required for next Level: 254
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Ort
    Sweden
    Beiträge
    1.779
    Points
    12.596
    Level
    73
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Vaza
    Hey,
    Anybody know if normal PC SDL is exactly the same as PSP SDL.
    If not, whats the difference?
    --Vaza
    I believe so, haven't worked that much with it though.


    Click Here if you want a Winamp Currently Playing Userbar like the one above.

  14. #1154
    likes kittens....awww....
    Points: 6.975, Level: 55
    Level completed: 13%, Points required for next Level: 175
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Detroit
    Beiträge
    628
    Points
    6.975
    Level
    55
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von homer
    I believe so, haven't worked that much with it though.
    hah lol ur not prem anymore

  15. #1155
    I'm Baaaack!
    Points: 17.067, Level: 83
    Level completed: 44%, Points required for next Level: 283
    Overall activity: 52,0%

    Registriert seit
    May 2006
    Ort
    Nowhere
    Beiträge
    2.186
    Points
    17.067
    Level
    83
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von psphacker12.
    hah lol ur not prem anymore
    First of all, why would you laugh at him for not being premium? And second of all, yes he is. He just changed the color of his name.

  16. #1156
    AKA Homer
    Points: 12.596, Level: 73
    Level completed: 37%, Points required for next Level: 254
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Ort
    Sweden
    Beiträge
    1.779
    Points
    12.596
    Level
    73
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von psphacker12.
    hah lol ur not prem anymore
    STFU you n00b.

    I am premium, I just changed the color to dark blue.


    Click Here if you want a Winamp Currently Playing Userbar like the one above.

  17. #1157
    likes kittens....awww....
    Points: 6.975, Level: 55
    Level completed: 13%, Points required for next Level: 175
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Detroit
    Beiträge
    628
    Points
    6.975
    Level
    55
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von homer
    STFU you n00b.

    I am premium, I just changed the color to dark blue.
    :Argh: sorry for laughing at you

  18. #1158
    sceKernelExitGame();
    Points: 19.955, Level: 89
    Level completed: 21%, Points required for next Level: 395
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Ort
    New York
    Beiträge
    3.126
    Points
    19.955
    Level
    89
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Vaza
    Hey,
    Anybody know if normal PC SDL is exactly the same as PSP SDL.
    If not, whats the difference?
    --Vaza
    The main differeces I know of is the control mapping and that a lot of SDL is done in software insteado hardware. The control mapping for SDL is all using a 'joystick' instead of buttons. Check out this thread: http://forums.ps2dev.org/viewtopic.p...49c129a3f2328f

    @psp12, Homer still has a sig, he HAS to be premium/dev... Use your common sense nd stop spamming the forums

  19. #1159
    likes kittens....awww....
    Points: 6.975, Level: 55
    Level completed: 13%, Points required for next Level: 175
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Detroit
    Beiträge
    628
    Points
    6.975
    Level
    55
    Downloads
    0
    Uploads
    0

    Standard

    okay I successfully installed the freetype lib
    but when I try to compile it gives me this.

  20. #1160
    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

    Add flib.o to the OBJS line in your makefile.

    You'll probably need graphics.o and framebuffer.o too.

    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

  21. #1161
    likes kittens....awww....
    Points: 6.975, Level: 55
    Level completed: 13%, Points required for next Level: 175
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Detroit
    Beiträge
    628
    Points
    6.975
    Level
    55
    Downloads
    0
    Uploads
    0

    Standard

    ok i included flib.o graphics.o and framebuffer.o
    but it gives me an error with flib

  22. #1162
    Heroes never die
    Points: 8.645, Level: 62
    Level completed: 65%, Points required for next Level: 105
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    ...........
    Beiträge
    1.323
    Points
    8.645
    Level
    62
    Downloads
    0
    Uploads
    0

    Standard

    beter copy and pasta you errors here;) and btw there is something wrong with your flib.o
    -= Double Post =-
    some prob's
    inline void vermenigvuldigen()
    { pspDebugScreenClear();
    x=0;
    while(1) {
    printf("\n\n\n\n\n\n\n je hebt vermenigvuldigen gekozen\n");
    if (x>=50) {
    printf(" bezig met opstarten");
    }
    if (x>200) {
    printf(",klaar");
    }
    if (x>250) {
    pspDebugScreenClear();
    vermenigvuldigenb();
    }
    }
    }
    it flips the text(je hebt vermenigvuldigen gekozen) 10.000 times on screen ,lol
    and the rest it dont

    prob2

    i let change the functions by pressing triangle
    but when you hold it , it change , change and change , it only ahve to change ones
    the prob is
    it loads another loop while pressing triangle and in the next loop it does the same , so it continues.....
    Geändert von hallo007 (10-08-2006 um 09:18 AM Uhr) Grund: Automerged Doublepost

  23. #1163
    likes kittens....awww....
    Points: 6.975, Level: 55
    Level completed: 13%, Points required for next Level: 175
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Detroit
    Beiträge
    628
    Points
    6.975
    Level
    55
    Downloads
    0
    Uploads
    0

    Standard

    i posted a pic..
    press back on your browser then forward..
    that should make the image normal size

  24. #1164
    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

    hallo007:
    Code:
    inline void vermenigvuldigen()
    { 
    	pspDebugScreenClear();
    	x=0;
    	while(1) 
    	{
    		printf("\n\n\n\n\n\n\n je hebt vermenigvuldigen gekozen\n");
    		if (x>=50) 
    		{
    			printf(" bezig met opstarten");
    		}
    		if (x>200) 
    		{
    			printf(",klaar");
    		}
    		if (x>250) 
    		{
    			pspDebugScreenClear();
    			vermenigvuldigenb();
    		}
    	}
    }
    Flipping heck... where do I start....
    1) You are inlining a function that really doesn't need to be inlined. Don't overuse the inline keyword and avoid premature optimisation.
    2) You are using an infinite loop (while(1) ) with no possbile exit condition.
    3) x is always going to be 0 before the while loop begins therefore none of the if statements will equal true.

  25. #1165
    Heroes never die
    Points: 8.645, Level: 62
    Level completed: 65%, Points required for next Level: 105
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    ...........
    Beiträge
    1.323
    Points
    8.645
    Level
    62
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von head_54us
    hallo007:

    2) You are using an infinite loop (while(1) ) with no possbile exit condition.
    3) x is always going to be 0 before the while loop begins therefore none of the if statements will equal true.
    2/it loads another function so why exit?
    3/ , how do i let it be true

  26. #1166
    likes kittens....awww....
    Points: 6.975, Level: 55
    Level completed: 13%, Points required for next Level: 175
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Detroit
    Beiträge
    628
    Points
    6.975
    Level
    55
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von hallo007
    2/it loads another function so why exit?
    3/ , how do i let it be true
    put
    Code:
    int x=0;
    in your while loop.
    -= Double Post =-
    Hey i have a question..
    In gimp, you can save images as image.c so cant you compile that image within the EBOOT to save memory space??
    Geändert von psphacker12. (10-08-2006 um 09:38 AM Uhr) Grund: Automerged Doublepost

  27. #1167
    Developer
    Points: 5.359, Level: 47
    Level completed: 5%, Points required for next Level: 191
    Overall activity: 0%

    Registriert seit
    Feb 2006
    Ort
    Norway
    Beiträge
    384
    Points
    5.359
    Level
    47
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von hallo007
    3/ , how do i let it be true
    if (x>=50)
    is true if x is larger then or equal to 50.
    but since you never make x increase nothing else will happen. add x++; or somthin


  28. #1168
    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

    psp12.: Incorrect

    hallo007: It doesn't even load another function since x is always 0 when entering the while loop.
    This:
    Code:
    inline void vermenigvuldigen()
    { 
    	pspDebugScreenClear();
    	x=0;
    	while(1) 
    	{
    		printf("\n\n\n\n\n\n\n je hebt vermenigvuldigen gekozen\n");
    		if (x>=50) 
    		{
    			printf(" bezig met opstarten");
    		}
    		if (x>200) 
    		{
    			printf(",klaar");
    		}
    		if (x>250) 
    		{
    			pspDebugScreenClear();
    			vermenigvuldigenb();
    		}
    	}
    }
    Might as well be:
    Code:
    inline void vermenigvuldigen()
    { 
    	pspDebugScreenClear();
    	x=0;
    	while(1) 
    	{
    		printf("\n\n\n\n\n\n\n je hebt vermenigvuldigen gekozen\n");
    	}
    }
    It won't ever leave the while loop.

  29. #1169
    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

    psp12: Your freetype headers are in the wrong directory. They should be in:

    Code:
    usr\local\pspdev\psp\include\freetype
    I seem to remember the ps2dev.org SVN putting them in a freetype2 folder or something like that.

    Just copy them into the usr\local\pspdev\psp\incl ude\freetype directory.

    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

  30. #1170
    QJ Gamer Blue
    Points: 4.511, Level: 42
    Level completed: 81%, Points required for next Level: 39
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Germany
    Beiträge
    216
    Points
    4.511
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard Socket-programming

    Socket-programming

    Hi,
    I'm doing some networkprogramming right now; The connecting works fine, but when it comes to the data exchange I'm having some issues; What he shall do is:

    1.) Client connects to server (works)
    2.) Client sends "<command>get_artists </command>" (works)
    3.) Server recieves message and prints it (works)
    4.) Client sends "<command>get_albums</command>" (works)
    5.) Server recieves message and prints it (works)
    6.) Client starts recieving (while-loop) (he starts recieving but never actually recieves something)
    7.) Server answers (never sends anything)

    Server code:
    Code:
        if(listen(sock, 5) == -1 )
             error_exit("Error listening");
    
        printf("Server ready - waiting for requests\n");
    
        for (;;) {
            len = sizeof(client);	// client = sockaddr_in
            fd = accept(sock, (struct sockaddr*)&client, &len);
            if (fd < 0)
    		error_exit("Error accepting");
    		
    	printf("Incloming request from %s\n", inet_ntoa(client.sin_addr));
    
    		while(rc!=SOCKET_ERROR)
    		{
    			rc=recv(fd,buf,256,0);
    			if(rc==0)
    			{
    				printf("Client closed the connection...\n");
    				break;
    			}
    			if(rc==SOCKET_ERROR)
    			{
    				printf("Error: recv, error-code: %d\n",WSAGetLastError());
    				break;
    			}
    			buf[rc]='\0';
    			printf("Client sent: %s\n",buf);
    		}
    
    		printf("Sending answer...\n");
    		sprintf(buf2,"%s\n",buf);
    		rc=send(fd,buf2,strlen(buf2),0);
    
    	printf("Closing connection...\n");
            closesocket(fd);
    Client code:
    Code:
        command = "<command>get_artists</command>";
        command_len = strlen(command);
        command2 = "<command>get_albums</command>";
        command2_len = strlen(command);
    
    	if (send(socket, command, command_len, 0) != command_len) {
            printf("send() sent a different length of bytes than expected!\n");		// needs real exceptionhandling
    		return;
    	}
    	printf("sending command get_artists...\n");
    
    	if (send(socket, command2, command2_len, 0) != command_len) {
            printf("send() sent a different length of bytes than expected!\n");		// needs real exceptionhandling
    		return;
    	}
    	printf("sending command get_albums...\n");
    
    	printf("recieving...\n");
    	while(rc!=SOCKET_ERROR)
    	{
    		rc=recv(socket,buf,4096,0);	// muss noch variabel gemacht werden
    		buf[rc]='\0';
    		if(rc==0)
    		{
    			printf("Server has closed the connnection\n");
    			break;
    		}
    		if(rc==SOCKET_ERROR)
    		{
    			printf("Error: recv, error-code: %s\n",strerror(errno));
    			break;
    		}
    		printf("%s\n", buf);
    		strcat(recivedMessage, buf);
    	}
       close(sock);
    what he does is, on the server, recieving and displaying the messages (nothing else), and on the client, he sends the 2 messages, displays 'reciecing and does nothing more


 

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 .