CS 5200 Distributed and Network Programming Fall 2005

CS 5200 Distributed and Network Programming Fall 2005

<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>

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    1 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us