network programming in c
... = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); Trang 24Accepting Connections#include <sys/types.h> #include <sys/socket.h> int connfd; struct sockaddr_in cliaddr; ... give structure to the address struct in_addr { in_addr_t s_addr; }; struct sockaddr_in { uint8_t sin_len; sa_family_t sin_family; in_port_t sin_port; struct in_addr sin_addr; char sin_pad[16];}; ... structure to the address struct in6_addr { uint8_t s6_addr[16];}; struct sockaddr_in6 { uint8_t sin6_len; sa_family_t sin6_family; in_port_t sin6_port; uint32_t sin6_flowinfo; struct in6_addr
Ngày tải lên: 05/09/2013, 09:57
... Summarize Processes #include #include #include #include #include #include #include #include #include #include #include #include #include “server.h” /* Set *UID and *GID to the owning user ... server.c (see Listing 11.4) is the implementation of the minimal HTTP server Listing 11.4 (server.c) Server Implementation #include #include #include #include #include #include #include #include #include ... common.c Listing 11.2 (common.c) General Utility Functions #include #include #include #include #include #include “server.h” const char* program_name; int verbose; void* xmalloc (size_t size) {
Ngày tải lên: 17/10/2013, 19:15
... http://www.fz-juelich.de/zam/cxx/ ➠ Parallel Programming with C++ ➠ Forschungszentrum Jülich Local C++ Information ❑ Official C++ On-line FAQ http://www.cerfnet.com/~mpcline/C++-FAQs-Lite/ This C++ Course ... = 0 ❑ Pascalrecords cannot be returned by functions int i; integer,target :: i var int *a; a : ^integer; integer,pointer :: a char *b, *c; b, c : ^char; character,pointer :: b, c Machine *mp; ... meeting (Lund, Schweden) Oct Cfront Release 3.0 (including templates) 1992 Feb 1st DEC C++ release (including templates and exceptions) Mar 1st Microsoft C++ release May 1st IBM C++ release (including
Ngày tải lên: 13/12/2013, 08:15
Tài liệu Programming with C# pdf
... 10: Inheritance in C# Overview 1 Deriving Classes 2 Implementing Methods 10 Using Sealed Classes 27 Using Interfaces 29 Using Abstract Classes 42 Lab 10.1: Using Inheritance to Implement an Interface ... terminology of object-oriented programming Use common objects and references types Create, initialize, and destroy objects in a C# application Build new C# classes from existing classes ... Windows Explorer, and in the root directory of the compact disc, double-click Default.htm or Autorun.exe Word document (.doc) files that are included on the compact disc Trang 14xiv Programming
Ngày tải lên: 21/12/2013, 06:16
Tài liệu Socket Programming in C# Part 1 – Introduction pptx
... m_socListener.Bind( ipLocal ); //start listening m_socListener.Listen (4); // create the call back for any client connections m_socListener.BeginAccept(new AsyncCallback ( OnClientConnect ... callback BeginAccept is a non-blocking method that returns immediately and when a client has made requested a connection, the callback routine is called and you can accept the connection by calling ... by calling EndAccept The EndAccept returns a socket object which represents the incoming connection Here is the code for the callback delegate: public void OnClientConnect(IAsyncResult asyn) {
Ngày tải lên: 18/01/2014, 08:20
Tài liệu Advanced Linux Programming: B Low-Level I/O docx
... 7 #include #include #include #include #include #include (write-args.c) Write the Argument List to a File with writev int main (int argc, char* argv[]) { int fd; struct iovec* vec; struct ... lseek #include <fcntl.h> #include <stdlib.h> #include <sys/stat.h> #include <sys/types.h> #include <unistd.h> int main (int argc, char* argv[]) { int zero = 0; const int ... I/O Listing B.1 (create-file.c) Create a New File #include <fcntl.h> #include <stdio.h> #include <sys/stat.h> #include <sys/types.h> #include <unistd.h> int main (int
Ngày tải lên: 21/01/2014, 07:20
Tài liệu Advanced Linux Programming: 2-Writing Good GNU/Linux Software pptx
... lscommand isinvoked twice and its exit code is printed after each invocation In the first case,lsexecutes correctly and returns the exit code zero In the second case,lsencounters anerror (because ... the coutand cinstreams in C++) thatprovide console input and output.These features are provided by the C and C++ languages, and they interact with the GNU/Linux system in certain ways GNU/Linux ... extensive errorchecking and recovery code because this would obscure the basic functionality beingpresented However, the final example in Chapter 11, “A Sample GNU/LinuxApplication,” comes back to demonstrating
Ngày tải lên: 21/01/2014, 07:20
Tài liệu Advanced Linux Programming: 4-Threads docx
... */ int process_transaction (int from_acct, int to_acct, float dollars) { int old_cancel_state; /* Check the balance in FROM_ACCT */ if (account_balances[from_acct] < dollars) return 1; continues ... (critical-section.c) Protect a Bank Transaction with a Critical Section /* Transfer DOLLARS from account FROM_ACCT to account TO_ACCT Return 0 if the transaction succeeded, or 1 if the balance FROM_ACCT ... create a cancellation point is to call pthread_testcancel.This doesnothing except process a pending cancellation in a synchronously cancelable thread.You should call pthread_testcancelperiodically
Ngày tải lên: 26/01/2014, 07:20
Tài liệu Advanced Linux Programming: 5-Interprocess Communication pptx
... ment process Under Linux, each process’s virtual memory is split into pages Eachprocess maintains a mapping from its memory addresses to these virtual memory pages,which contain the actual data ... 8Listing 5.2 (sem_all_deall.c) Allocating and Deallocating a Binary Semaphorestruct semid_ds *buf; unsigned short int *array; struct seminfo * buf; }; /* Obtain a binary semaphore’s ID, allocating ... Each value is used to initialize one sema-phore in the set sema-Listing 5.3 presents a function that initializes a binary semaphore Listing 5.3 (sem_init.c) Initializing a Binary Semaphore #include
Ngày tải lên: 26/01/2014, 07:20
Tài liệu Advanced Linux Programming: 6-Mastering Linux ppt
... ioctl is used Listing 6.2 (cdrom-eject.c) Eject a CD-ROM #include #include #include #include #include #include int main (int argc, char* argv[]) { /* Open a file descriptor to the device ... Devices Exercise Caution When Accessing Devices! The techniques in this chapter provide direct access to device drivers running in the Linux kernel, and through them to hardware devices connected ... Ctrl+C when you’re convinced that it will go on indefinitely. Memory mapping /dev/zero is an advanced technique for allocating memory. See Section 5.3.5,“Other Uses for mmap,” in Chapter 5,“Interprocess
Ngày tải lên: 26/01/2014, 07:20
Tài liệu Advanced Linux Programming: 8-Linux System Calls doc
... access that memory.The example in Listing 8.7 illustrates this technique Listing 8.7 (mprotect.c) Detect Memory Access Using mprotect #include #include #include #include #include #include #include ... second It uses fstat to determine the size, in bytes, of the source file Listing 8.10 (copy.c) File Copy Using sendfile #include #include #include #include #include #include #include int ... existence and to determine read and write permissions Specify the name of the file to check on the command line Listing 8.1 (check-access.c) Check File Access Permissions #include #include #include
Ngày tải lên: 26/01/2014, 07:20
Tài liệu Advanced Linux Programming: 10-Security ppt
... examining the permissions associated with theresources that the process is trying to access and by checking the user ID and group com-ID associated with the process trying to perform the action ... samuel csl 11734 Jan 22 16:29 helloThe samueland cslfields indicate that the owning user is samueland that the owninggroup is csl The string of characters at the beginning of the line indicates ... thesticky bit on the directory.You can set the sticky bit on a directory with the chmodcommand by invoking the following: % chmod o+t directory 5.This name is anachronistic; it goes back to a
Ngày tải lên: 26/01/2014, 07:20
Data structures in c++ pdf
... push(struct stack*); void pop(struct stack*); int full(struct stack*); int empty(struct stack*); Trang 1212 ن أ G QXا C , ن أاذإ U L^ نإ ت, rC ه هtCأ نأOCIC نذإءو, 5)#include<iostream.h> ... "; p=p->last;} cout<<endl;} #include<iostream.h> #include<conio.h> Trang 4040 struct list{int d;list*last;}; Trang 41 K,و M Mد[=ا ت-C J روM و (* (DELETE) ... if(a[m]!=k){ Trang 1818 نإ cو YK- إو S- Uإ 10)#include<iostream.h> int p_q(){return a[head++];} void ser(int a[],int k){int y=0,t=tail,h=head; if(t==-1||h>t)cout<<"THE QUEUE
Ngày tải lên: 05/03/2014, 20:20
Socket Programming in C/C++ ppt
... 1Socket Programming in C/C++cSeptember 24, 2004 Trang 3Sockets are a protocol independent method of creating a connection between processes Sockets can be either I connection based or connectionless: ... connection is completed, thesocket is closed, and next connection can beaccepted Forking server: After an accept, a child process is forked off to handle the connection Variation: the child processesare ... build a concurrent server: I a fork is performed after the accept I The child process closes listenFd, and communicates usingconnectFd I The parent process closses connectFd, and then loops back tothe
Ngày tải lên: 15/03/2014, 17:20
Tài liệu Advanced Linux Programming: 3-Processes pdf
... Cleaning Up Children by Handling SIGCHLD #include #include #include #include sig_atomic_t child_exit_status; void clean_up_child_process (int signal_number) ... that contain the letter l (execl, execlp, and execle) accept the argument list using the C language’s varargs mechanism Functions that contain the letter e in their names (execve and execle) accept ... processes into an instance of the program you want to spawn Calling fork When a program calls fork, a duplicate process, called the child process, is created.The parent process continues executing...
Ngày tải lên: 26/01/2014, 07:20
Tài liệu Advanced Linux Programming: A-Other Development Tools pdf
... object files and linking For example, consider this code: % % % % gcc gcc gcc gcc -pg -pg -pg -pg -c -o calculator.o calculator .c -c -o stack.o stack .c -c -o number.o number .c calculator.o stack.o ... object files must be linked with ccmalloc’s library and the dynamic linking library Append -lccmalloc -ldl to your link command, for instance % gcc -g -Wall -pedantic malloc-use.o -o ccmalloc-use ... not contain valid symbols trying to find executable in current directory using symbols from ‘ccmalloc-use’ (to speed up this search specify ‘file ccmalloc-use’ in the startup file ‘.ccmalloc’)...
Ngày tải lên: 21/01/2014, 07:20
Tài liệu Advanced Linux Programming: 1-Advanced UNIX Programming with Linux pdf
... reciprocal.o g++ $(CFLAGS) -o reciprocal main.o reciprocal.o main.o: main .c reciprocal.hpp gcc $(CFLAGS) -c main .c reciprocal.o: reciprocal.cpp reciprocal.hpp g++ $(CFLAGS) -c reciprocal.cpp clean: ... #include “reciprocal.hpp” int main (int argc, char **argv) { int i; i = atoi (argv[1]); printf (“The reciprocal of %d is %g\n”, i, reciprocal (i)); return 0; } Listing 1.2 (reciprocal.cpp) C+ + ... command prompt compiles the main .c source file: % gcc -c main .c The resulting object file is named main.o The C+ + compiler is called g++ Its operation is very similar to reciprocal.cpp is accomplished...
Ngày tải lên: 21/01/2014, 07:20
Tài liệu Advanced Linux Programming: 7-The /proc File System pdf
... the function get_cpu_clock_speed that reads from /proc/cpuinfo into memory and extracts the first CPU’s clock speed Listing 7.1 (clock-speed .c) Extract CPU Clock Speed from /proc/cpuinfo #include ... read 09 0430 CH07 5/22/01 10:30 AM Page 153 7.2 Listing 7.3 (print-arg-list .c) Print the Argument List of a Running Process #include #include #include #include #include #include ... determine where that executable actually is.The function get_executable_path in Listing 7.5 determines the path of the executable running in the calling process by examining the symbolic link /proc/self/exe...
Ngày tải lên: 26/01/2014, 07:20
A Complete Guide to Programming in C++ part 20 pdf
... // Beginning // Function block // End DEFINING FUNCTIONS ■ 175 The following section describes how to program global functions Chapter 13, Defining Classes, describes the steps for defining member ... identifying objects you will need to define classes that describe these objects You can use available classes and functions to so In addition, you can make use of inheritance to create specialized classes ... compiler/linker settings for program compilation 174 ■ CHAPTER 10 ■ FUNCTIONS DEFINING FUNCTIONS Example of a function definition // func1.cpp #include using namespace std; void test( int, double...
Ngày tải lên: 06/07/2014, 17:21