Crea sito

Archivio per dicembre 2010

Received tcp packets from a socket (C language)

Here there is an example of a simple tcp receiver (server) #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <errno.h> #define SOCKET_ERROR   ((int)-1) #define SIZEBUF 1000000 void usage(void) {  printf (“usage: servTCP LOCAL_PORT_NUMBER\n”); exit(1); } int main(int argc, char *argv[]) { #define MAXSIZE 1000000 struct sockaddr_in […]

Tags: , , ,

Send tcp packet over socket (C language)

Here there is an example of a simple tcp sender #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <errno.h> #define SOCKET_ERROR   ((int)-1) #define SIZEBUF 1000000 void usage(void) {  printf (“usage: cliTCP REMOTE_IP_NUMBER REMOTE_PORT_NUMBER\n”); exit(1); } int main(int argc, char *argv[]) { #define MAXSIZE 1000000 struct sockaddr_in […]

Tags: , , ,

Received an UDP stream with a socket (C language)

Here there is an example of how read a stream udp received from the network using a socket #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <errno.h> #include <stdio.h> #include <arpa/inet.h> #define SOCKET_ERROR   ((int)-1) #define SIZEBUF 100000L void usage(void) {  printf (“parameters: LOCAL_PORT_NUMBER, IP ADDRESS (the latter is not necessary)\n”); exit(1); } int main(int argc, char […]

Tags: , , ,

Send udp stream over a socket (C language)

Here there is an example of a simple program that use a socket to send datagram UDP on the network #include<stdio.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <errno.h> #define SOCKET_ERROR   ((int)-1) #define SIZEBUF 100000L int main(int argc, char * argv[]){ char  ip_dest[100]; char  ip_source[100]; short int port_dest, port_source; int socketfd, OptVal, addr_size; int ris, […]

Tags: , , ,

forget the root password

Sometimes it happen to forget the root password. There are always to many passwords to remember and sometimes also different computer and then different root password to remember. This will explain what to do if you forget the root password How to change root password if you have forgot it: -Start machine. -At Grub prompt […]

Tags: , ,