Message-ID: <3634D8C9.B4DF95E7@clover.c2d.fedex.com> Date: Mon, 26 Oct 1998 14:17:13 -0600 From: Walter Moore Organization: Federal Express X-Sender: "Walter Moore" (Unverified) X-Mailer: Mozilla 4.04 [en]C-FedExIntl (Win95; I) MIME-Version: 1.0 To: "djgpp AT delorie DOT com" Subject: porting socket based client server from Unix to win95 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp AT delorie DOT com Hi all. I thought I'd write a note explaining everything I had to do to port client/server programs from UNIX to Win95, using DJGPP, RSXNTDJ, winsock.h, and wsock32.dll. Note, the project was originally compiled with gcc on solaris 2.5. 1. get and install dgjpp, and rsxntdj, use the zip picker found at: http://www.delorie.com/djgpp/ you'd need C, C++ and assembler, you can get rhide if you like integrated environments, I never used it, though I did install it. I did not need the extra documentation formats, as the zip files with the binaries had the man pages. You'll DEFINITELY need RSX, so as to be able to use the Win95 wsock32.dll. I ended up installing most of the DJGPP software to have a complete unix-like environment (djdev201, djlsr201, djst201, djcrx201, faq210b, rhide11b, binutils, bash, bison, diffutils, fileutils, findutils, fles, gcc, gdb, gpp, grep, awk, gzip, ispell, libg++, less, make, ObjC, path, sed, sh-utils, textutils, rsxntdj), so you might need more than just the stuff before the more complete list. I also ended up moving all the *.1 *.5n and *.7n files from c:\djgpp\info into c:\djgpp\man\man1, man5, and man7, renaming the *.5n to *.5 and *.7n to *.7 so man would work better. besure to read each readme file that comes with the various packages, as there is often something that needs to be added to autoexec.bat or c:\djgpp\djgpp.env. 2. get, install and patch the MSSDK headers for use with RSXNTDJ: get http://webhome.idirect.com/~eschunk/mssdk/rsxpatch.zip unzip rsxpatch.zip (assume to \tmp) get http://mssjus.www.conxion.com/msdownload/platformsdk/i386/iBLDENV.Exe run iBLDENV.Exe (assume to c:\MSSDK) copy c:\MSSDK\include\*.* \rsxntdj\include\mssdk copy c:\tmp\patch.exe c:\djgpp\contrib\rsxntdj\include\mssdk copy c:\tmp\sdkpatch.dif c:\djgpp\contrib\rsxntdj\include\mssdk cd c:\djgpp\contrib\rsxntdj\include\mssdk patch and not use the usual include files for networking. Here were my include files: #ifdef __DJGPP__ #include #else #include #include #include #include #include #endif /* DJGPP */ #include #include #include #include #include #include 5. if you used getopt(), you'll need to redefine the following: #define getopt _getopt #define optarg _optarg #define optind _optind Along these lines, if you use the 'extern int environ', you will have to declare it in the main definition, like: main(int argc, char **argv, char **environ) and you'll have to pass it to any subroutines, otherwise, the compiler will try to link in winmain(). you may also have to #define environ _environ (although since I did the above definition of main, it was not necessary). 6. If you used read() and write(), and declared the sockets as int, you'll have to change declarations of sockets from int to SOCKET, and change all error checking of sockets from -1 or < 0 to check for INVALID_SOCKET: check bind() result for SOCKET_ERROR, rather than <0 check accept() result for INVALID_SOCKET rather than -1 check socket() result for INVALID_SOCKET rather than -1 check connect() result for SOCKET_ERROR rather than -1 and define these in a header: #define read(sock,buf,len) recv(sock,(LPSTR)buf,len,0) #define write(sock,buf,len) send(sock,buf,len,0) 7. start MS Windows' socket API at beginning of main(): #ifdef __DJGPP__ /****************************************************************/ /* Lets let the Windows Socket API startup, */ /* telling it we want Winsock 1.1. */ /****************************************************************/ WSADATA wsaData; if (WSAStartup(MAKEWORD(1,1), &wsaData) != 0) { return 255; } #endif 8. Shutdown the MS Windows' socket API at end of main(): #ifdef __DJGPP__ /****************************************************************/ /* Lets let the Windows Socket API cleanup. */ /****************************************************************/ /* blocking call ? */ if (WSAIsBlocking()) { WSACancelBlockingCall (); } WSACleanup (); #endif 9. Using the makelib that came with rsxntdj: makelib /windows/system/wsock32.dll -o wsock32.a mv wsock32.a libwsock32.a 10. be sure to compile with the -Zwin32 flag and link with the -I. lwsock32 flags, ensuring the right things are compiled and linked in. Good luck! Walter Moore -- Walter Moore Sr. Programmer Analyst Federal Express wbmoore AT fedex DOT com 2813 Business Park Memphis TN 38118 USA work: 901-369-2640 fax: 901-369-3634