Aurelio
Sunday 24 June 2007 - 20:16
Aspettate.Io il codice l'ho fatto.è questo:
CODICE
// Includes
#include <PA9.h> // Include for PA_Lib
#define server "i don't have it yet"
char text[256]; // This will be our text...
char textrecv[256]; //This is the text that we will receive
s32 scroll=0;
// Function: main()
int main(int argc, char ** argv)
{
PA_Init(); // Initializes PA_Lib
PA_InitVBL(); // Initializes a standard VBL
PA_InitText(1, 0); // Initialise the text system
PA_InitText(0, 0);
PA_InitKeyboard(2); // Load the keyboard on background 2...
PA_KeyboardIn(20, 95);
PA_InitWifi(); //Initializes the wifi
PA_ConnectWifiWFC();
int sock;
s32 nletter = 0; // Next letter to right. 0 since no letters are there yet
char letter = 0; // New letter to write.
// Infinite loop to keep the program running
PA_InitSocket(&sock,server,80,PA_NONBLOCKING_TCP);
PA_OutputText(0,0,8,"Ready");
while (1)
{
letter = PA_CheckKeyboard();
if (letter > 31) { // there is a new letter
text[nletter] = letter;
nletter++;
}
else if ((letter == PA_BACKSPACE)&&nletter) { // Backspace pressed
nletter--;
text[nletter] = ' '; // Erase the last letter
}
else if (letter == '\n'){ // Enter pressed&send
send(sock,text,256,0);
PA_OutputText(1,0,scroll,"%s",text);
scroll++;
}
PA_OutputText(0, 0, 0, text); // Write the text received
recv(sock,textrecv,256,0);
if(textrecv[0]!='\0'){
PA_OutputText(1,0,scroll,"%s",textrecv);
scroll++;
}
PA_WaitForVBL();
}
return 0;
} // End of main()
Ma adesso mi serve un server da usare con questo programma.C'è qualcuno che mi sappia dire come e se è corretto questo codice?
PS:è commentato in inglese perchè l'avevo già postato sul sito palib