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


 
Thread Tools Search this Thread
Top Forums Programming Using Cygwin, how do I make eclipse recognize C's Socket library?
# 1  
Old 10-29-2007
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 Smilie

Many thanks.
# 2  
Old 10-29-2007
Quote:
Originally Posted by wannabeTekkie
I am trying to develop a simple program that uses Sockets. I have a windows machine and MUST use C++.
Why not just write a Win32 C++ program using winsock?

Quote:
Originally Posted by wannabeTekkie
How do I point eclipse to the socket.h
Or you could keep things simple and just use vi and make.

Code:
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"

Code:
#include <sys/socket,h>

# 3  
Old 10-29-2007
[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!
# 4  
Old 10-29-2007
Code:
#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;
}

# 5  
Old 10-30-2007
O wow, thanks, I didnt know I could do that! Smilie
/WannabeTekkie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

How to make use others' C library installed not for the system-wide (Ubuntu/Linux)?

I have downloaded and installed a library called htslib for specific bioinformatic use but not for the system (I'm using Ubuntu 18.04). Only parts of the library is needed for my exercise to parse data in a type called VCF format (basically tab-delimited file but contains many information in... (14 Replies)
Discussion started by: yifangt
14 Replies

2. AIX

AIX full path to socket library

Can somebody help me too identify full path to socket library on AIX? Cannot find anything Thanks for contribution (2 Replies)
Discussion started by: digioleg54
2 Replies

3. Programming

Boost library path for cmake & make

I was compiling a downloaded open source pkg. Following the install instruction, I did $ mkdir build; cd build; cmake ../; make but got error message:make: *** No rule to make target 'usr/lib64/lib64/libboost_graph-mt.so.5'. needed by ../bin.gam-create. stop make: *** Error 2 make: *** Error... (1 Reply)
Discussion started by: yifangt
1 Replies

4. Shell Programming and Scripting

opening new instance of cygwin from withing cygwin

I'm using cygwin on win7, What I would like to do is something like this: cygstart cygwin tail -f /foo/test.log | perl -pe 's/error/\e I know I can start a new instance using either of these: mintty -e ... cygstart tail ... But neither of those open in ANSI mode, so I can't do... (0 Replies)
Discussion started by: Validatorian
0 Replies

5. UNIX for Dummies Questions & Answers

Cross complie linux make files onto a windows 7 machine using PGI Cygwin

Hello, I am very unfamiliar with linux/unix (don't even know the difference), but am trying to get some linux software to run on my Windows machine for my research. I have the makefiles for the software, and it is designed to be compiled in the PGI complier, which I also have. When i... (6 Replies)
Discussion started by: roba87
6 Replies

6. IP Networking

Clarification - Setting socket options at the same time when socket is listening

I need clarification on whether it is okay to set socket options on a listening socket simultaneously when it is being used in an accept() call? Following is the scenario:- -- Task 1 - is executing in a loop - polling a listen socket, lets call it 'fd', (whose file descriptor is global)... (2 Replies)
Discussion started by: jake24
2 Replies

7. Cybersecurity

Help Make a spoofing DNS using pcap library

Hello all, i need your quick help. I have assignment project class to make a program using pcap library to spoofing DNS in linux environment. Can anyone help me, because i'm newbie in network security and in C?:confused: Regards, ptrfw (1 Reply)
Discussion started by: riska_bali
1 Replies

8. Programming

Socket++ library problem.

Hi, My name is Daniel and I'm spanish, so I'm sorry if you can't undertand something becouse of my low-level english. Something stranger is happening to me with socket++ library and I don't know how to work on it. I has a library called commands.so and the sslclient is and object of that... (4 Replies)
Discussion started by: lock.cda
4 Replies

9. UNIX for Advanced & Expert Users

make/Oracle : Unable to find library 'libclntsh.sl.9.0

Hi all, If any of DBA/build experts can help me on solving this issue, it would be of great help: Recently Oracle was upgraded from 9.2.0.6 to 9.2.0.8 version, after this our C/ProC build is is erroring out by giving the following error : 860:/usr/lib/pa20_64/dld.sl: Unable to find library... (1 Reply)
Discussion started by: shihabvk
1 Replies

10. UNIX for Advanced & Expert Users

connect problem for sctp socket (ipv6 socket) - Runtime fail Invalid Arguments

Hi, I was porting ipv4 application to ipv6; i was done with TCP transports. Now i am facing problem with SCTp transport at runtime. To test SCTP transport I am using following server and client socket programs. Server program runs fine, but client program fails giving Invalid Arguments for... (0 Replies)
Discussion started by: chandrutiptur
0 Replies
Login or Register to Ask a Question