Click to See Complete Forum and Search --> : Socket Question


elitewhiteghost
03-08-2004, 01:35 PM
I try to make a program that can connect to a windows box.I not sure what headers i need.I thought windows use more headers in there programs more then linux is that true?



Any ideas?:D

tecknophreak
03-08-2004, 02:44 PM
Yes, windows uses other includes and requires a few different calls to get up and running. Check out the bottom of the first page of this pdf: http://www.apogeelabs.com/pdffiles/AP30_a_grebe.pdf

It's just a little example of windows/unix socket programming.

bwkaz
03-08-2004, 08:28 PM
I'm pretty sure that if you include <ws2_32.h>, you can use the normal BSD socket functions. But I'm not entirely sure, since I've never bothered...

elitewhiteghost
03-09-2004, 11:53 AM
So if i want to port my program to work on windows i use this header i take it winsock.h But it i want to to work with other os to.But try to find what other headers to use?


programming is fun to learn.:):D

tecknophreak
03-09-2004, 12:25 PM
Here's an example of how to set this up, I wrote a program with sockets which would compile on Unix/Linux/Windows(XP). So the following is how I got the program to compile with the correct headers.


#ifdef __unix__

#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <unistd.h>

#elif _WIN32

#include <windows.h>
#include <winsock.h>
#include <conio.h>

#endif

Good?

elitewhiteghost
03-09-2004, 01:20 PM
Yes it look good to me.Now i know how to start make a windows program on from a linux box.Now i got to find a way to get it to work remote:)



Thanks for the help:)

bwkaz
03-09-2004, 08:49 PM
Originally posted by elitewhiteghost
Now i know how to start make a windows program on from a linux box. You do realize that you can't compile for Windows while on a Linux box, right? You can't create a .exe file (well, you can call it a .exe, but the file format that gcc creates is different from what Windows expects its binaries to be in).

hammer123
03-10-2004, 05:12 AM
You do realize that you can't compile for Windows while on a Linux box, right? cross comiling windows applications on linux is possible. After that they can be run in wine. Documentation for this exists but gentoo makes it a few simple emerge commands. As far as networking goes I don't want to learn the windows api or go through the steps to acquire it so I learned wxwidgets. This makes it so I can develop for windows without ever having it or booting into it. Documentation for this also exists

elitewhiteghost
03-10-2004, 12:03 PM
I not planning to use wine for my tool i makeing.I just want to use it remote over the internet.I know some freinds made some tool that did work remote over the intenet from a linux box.



Samething with a mac pc to.