Using Cygwin, how do I make eclipse recognize C's Socket library?

Hi,
I am trying to develop a simple program that uses Sockets. I have a windows machine and MUST use C++. I found out that I can use C's Socket (#include <sys/socket.h>) API calls, but this is only possible on a unix machine. So I installed Cygwin to imitate a unix environment on my windows machine. I already had MinGW on my machine, and now I have Cygwin too. I appended, to my system variable (Control Panel/System/Advanced/Environment Variables) called Path, C:\cygwin\bin.

Q1) How do I launch eclipse from "within cygwin" (ie. "bash")? I copied the eclipse folder from my C:\ drive to my cygwin folder, but when i CD into the eclipse folder and type eclipse.exe it says command not found (even though ls reports the exe).

Q2) How do I point eclipse to the socket.h file, which is located within my "home" root (ie. within C:\cygwin\ path). This question might not be relevant to this forum, but if you know a quick answer, here is a chance to score some quick karma cookies :slight_smile:

Many thanks.

Why not just write a Win32 C++ program using winsock?

Or you could keep things simple and just use vi and make.

all: myapp

myapp.o: myapp.cpp
      $(CXX) $(CXXFLAGS) -c myapp.cpp -o $@

myapp: myapp.o
      $(CXX) $(CXXFLAGS) myapp.o -o $@

BTW, "socket.h" is always refered to as "sys/socket.h"

#include <sys/socket,h>

[quote=porter;302142675]
Why not just write a Win32 C++ program using winsock?

If I use winsock, will I be able to run my program on a unix machine?
Conversly, if I use sys/socket.h, will I be able to run my program on a windows machine?

thanks!

#include <sys/types.h>
#ifdef _WIN32
#include <winsock2.h>
#else
#include <sys/socket.h>
#include/netinet/in.h>
#include <netdb.h>
typedef int SOCKET;
#define INVALID_SOCKET  ((SOCKET)-1)
#define closesocket(fd)    close(fd)
#endif

int main(int argc,char **argv)
{
SOCKET fd;
#ifdef _WIN32
WSADATA wsd;
     if (WSAStartup(0x101,&wsd)) return 1;
#endif

     fd=socket(AF_INET,SOCK_STREAM,0);

....

#ifdef _WIN32
     WSACleanup();
#endif

    return 0;
}

O wow, thanks, I didnt know I could do that! :b:
/WannabeTekkie