![CS 5200 Distributed and Network Programming Fall 2005](https://data.docslib.org/img/3a60ab92a6e30910dab9bd827208bcff-1.webp)
<p>CS 5200 Distributed and Network Programming Fall 2005</p><p>Winsock – sockets under Windows Since the socket API is a de facto standard in the networking industry, Microsoft has also adopted the socket API. there are only a few minor differences when using the socket API under Windows.</p><p>1. A different set of header files #include <Winsock2.h> // Windows #include <io.h> // Windows #include <process.h> // Windows 2. A socket API initiation call WSADATA wsadata; if (WSAStartup (0x102, &wsadata) != 0) { printf ("WSA startup error\n"); exit(0); }</p><p>3. A formal declaration of the SOCKET data type (as opposed to just int under Linux)</p><p>SOCKET s;</p><p>4. Under Linux, either the POSIX standard close() or the formal closesocket() functions may be used. Under Windows, you must use the formal closesocket() function.</p><p>Threads and Processes under Windows</p><p>Windows does not support the Linux fork() call to create a process. It does however, provide the _beginthread() function to create a thread. While implementation details are different, a thread is similar to a process with the following exceptions; a) A created thread shares global variables, file descriptors, and other system resources owned by the parent. b) A created thread may not replace its code page and must continue to share the parent’s code page. (NOTE: While _beginthread() allows passing of arguments to the new thread, use only explicit constants to avoid problems with shared variables.) The following example creates a new thread with the same stack size as the parent and begins execution at function thisfunc() with a single integer argument of 99;</p><p>_beginthread (( void (*)(void*)) addem, 0, (void *) 99); … void thisfunc (int x) {…</p><p>Determining an IP address</p><p>Under Windows, use a command prompt window and run the command ipconfig</p><p>> ipconfig</p><p>Under Linux, run the command ifconfig</p><p>$ ifconfig</p><p>08ceebc918953c360b2b36c10538f3e9.doc Page 1 4/26/2018</p>
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages1 Page
-
File Size-