Friday, February 26, 2010

Bow And Arrow Pc Game

(MOVED) Use of Bluez 4.xx

We want to illustrate
the configuration of a Gentoo Linux system to use a bluetooth device with the Blue-z version 4.xx

This post has been moved to:

http://freeehowto.wordpress.com/ 2010/04/30/uso-di-bluez-4-xx-in-gentoo-linux /

Thursday, February 11, 2010

Titles For Birthday Event On Facebook

VirtualBox in Gentoo Linux: Mounting a shared folder on a Ubuntu guest

VirtualBox, the application of Sun's open source virtualization, allows set up shared folders between host and guest. On the host system folders are shared with the appropriate configuration menu of each virtual machine VirtualBox, when sharing the folder you assign it a name, such as SharedFolder .
If a guest is a system installed Ubuntu (or Linux in general) to mount the shared folder is given the command:
sudo mkdir / mnt / SharedWin
mount.vboxsf SharedFolder sudo / mnt / SharedWin
To be noted that the system must be installed VirtualBox Guest Addition

Sunday, February 7, 2010

Alabama History Of Number 12

About rezdore

In "Cultivating Connections", he cites the DVD "Tales of land and rezdore" and, curiously, I did a search on YouTube. I found this excerpt from the movie, published by courtesy of the Province of Modena.
Do not miss ...

Thursday, February 4, 2010

Antennasatellite.gr/recepis

Implementation of a TCP server in multithreaded C, C + +

The initial part of the program must include the necessary the use of socket:

# include # include # include

# include

int main (int argc, char * argv []) {
int sockfd;
newsockfd int = 0;
; struct sockaddr_in serv_addr, cli_addr;
you create the socket for the server
sockfd = socket (AF_INET, SOCK_STREAM, 0);
if ( sockfd \u0026lt;0) {
perror ("FATAL: Unable to open TCP listener");
exit (1);}
you bind on ' address / port wanted
bzero ((char *) & serv_addr, sizeof (serv_addr));
serv_addr.sin_family = AF_INET;
serv_addr . sin_addr.s_addr = INADDR_ANY;
serv_addr.sin_port = htons (0x4bfc)
if (bind (sockfd, (struct sockaddr *) & serv_addr, sizeof (serv_addr)) \u0026lt;0) {
perror ("FATAL: Unable to bind the TCP listener ");
exit (1);}
and listens to
listen (sockfd, 5);
at this point for each new incoming connection is accepted create a specific thread that runs it. E 'must wait to be sure that the new thread has taken over the value of the socket to use for communication.
while (true) {socklen_t
clilen = sizeof (cli_addr)
newsockfd = accept (sockfd, (struct sockaddr *) & cli_addr, & clilen) if
(Newsockfd \u0026lt;0) {perror
("New connection created");
;} else {
pthread_t pth;
; pthread_create (& pth, NULL, InitiateThreadTCP, (void *)newsockfd);
            pthread_detach(pTh);
            int maxsleep = 1000;
            while (newsockfd > 0 && maxsleep > 0) {
                usleep (1000);
maxsleep -;
;}}
}
Gestin the function of communication is the Next, remember to define the beginning del file prima del main.
void * InitiateThreadTCP( void *p )
{
    int sck = &(int *)p;
    char rbuffer[1000];
    char sbuffer[1128];
 
    int n = read(sck, rbuffer, 1022);
    if (n >= 0) {
        rbuffer[n] = 0;
        sprintf (sbuffer, "Received message:% s", rbuffer)
write (SCK sbuffer, strlen (sbuffer));}

close (SCK);
pthread_exit (NULL);}
Here is the complete source

# include # include # include

# includes

InitiateThreadTCP void * (void * p)

SCK = & {int (int *) p;
rbuffer char [1000];
sbuffer char [1128];
int n = read (SCK rbuffer, 1022);
if (n> = 0) {
rbuffer [n] = 0;
sprintf (sbuffer, "Received messaggio: %s ", rbuffer);
        write(sck, sbuffer, strlen(sbuffer));
    }
    close(sck);
    pthread_exit( NULL );
}

int main(int argc, char *argv[])
{
    int sockfd;
    int newsockfd = 0;
    struct sockaddr_in serv_addr, cli_addr;

    sockfd = socket(AF_INET, SOCK_STREAM, 0);
    if ( sockfd < 0 ) {
        perror("FATAL: Impossibile aprire il listener TCP");
        exit(1);
    }

    bzero((char *) &serv_addr, sizeof(serv_addr));
    serv_addr.sin_family = AF_INET;
    serv_addr.sin_addr.s_addr = INADDR_ANY;
    serv_addr.sin_port = htons(0x4bfc);
    if ( bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0 ) {
        perror("FATAL: Impossibile effettuare il bind del listener TCP");
        exit(1);
    }
 
    listen(sockfd,5);

    while( true ) {
        socklen_t clilen = sizeof(cli_addr);
        newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
        if (newsockfd \u0026lt;0) {perror
("New connection created");

} else {pthread_t pth;
pthread_create(&pTh, NULL, InitiateThreadTCP, (void *)newsockfd);
            pthread_detach(pTh);
            int maxsleep = 1000;
            while (newsockfd > 0 && maxsleep > 0) {
                usleep(1000);
                maxsleep--;
            }
        }
    }

    exit(0);
}