Thread: RE: [Dev-C++] Get socket with socket function
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Reid T. <Rei...@at...> - 2003-10-29 21:59:50
|
If you configure Dev-C++ to use cygwin as the build env you will not have to change your code. =20 =20 reid=20 -----Original Message----- From: Alain Paschoud [mailto:ala...@ge...]=20 Sent: Wednesday, October 29, 2003 3:16 PM To: dev...@li... Subject: [Dev-C++] Get socket with socket function =09 =09 Hi all,=20 I managed to compile a simple program that should just wait for an icoming connection on a inet type socket. I did it under Mac OS X and Linux, and I want to do the same thing with dev-cpp.=20 Due to explanation give on this mailing list (thanks for your quick and usefull answers), I change the code to use winsock.h instead of sys/socket.h. I added the necessary library and DLLs. The program starts correctly and get it the function to create the socket file descriptor (it is very simple) :=20 int sockfd;=20 sockfd =3D socket(AF_INET, SOCK_STREAM, 0);=20 BUT the result of socket function is always -1 (sockfd =3D -1). What could be the cause of that ? I found a similar example of socket creation for windows, I did exactly the same as in the example. The only thing I have found in "socket" man page is :=20 "A -1 is returned if an error occurs"=20 But how can an error happen at this step ?=20 Thank you for any advice.=20 Best regards. |
|
From: P.D. v. Z. <pa...@my...> - 2003-10-29 23:48:33
|
But your application will be dependent on the Cygwin DLLs, which can be a nuisance. I always prefer native code over emulation, especially when the emulation requires 3rd party libraries. ________________________________ From: dev...@li... [mailto:dev...@li...] On Behalf Of Reid Thompson Sent: Wednesday, October 29, 2003 11:00 PM To: Alain Paschoud; dev...@li... Subject: RE: [Dev-C++] Get socket with socket function If you configure Dev-C++ to use cygwin as the build env you will not have to change your code. reid -----Original Message----- From: Alain Paschoud [mailto:ala...@ge...] Sent: Wednesday, October 29, 2003 3:16 PM To: dev...@li... Subject: [Dev-C++] Get socket with socket function Hi all, I managed to compile a simple program that should just wait for an icoming connection on a inet type socket. I did it under Mac OS X and Linux, and I want to do the same thing with dev-cpp. Due to explanation give on this mailing list (thanks for your quick and usefull answers), I change the code to use winsock.h instead of sys/socket.h. I added the necessary library and DLLs. The program starts correctly and get it the function to create the socket file descriptor (it is very simple) : int sockfd; sockfd = socket(AF_INET, SOCK_STREAM, 0); BUT the result of socket function is always -1 (sockfd = -1). What could be the cause of that ? I found a similar example of socket creation for windows, I did exactly the same as in the example. The only thing I have found in "socket" man page is : "A -1 is returned if an error occurs" But how can an error happen at this step ? Thank you for any advice. Best regards. |
|
From: Reid T. <rei...@at...> - 2003-10-30 03:39:49
|
My opinion differs. I am only offering an alternative that may provide
alain the means
to get the end result he wants w less code modification. I imagine he
could as easily configure
Dev-C++ to use borlands compiler/libs/dlls. His choice. But,
I have no issue with my application utilizing the cygwin dll.
In my opinion, cygwin more than makes up for that by:
providing a posix/linux/unix env to work in
providing ~all the tools of a *nix environment
allowing me to run any Xwindows client i desire
providing me the ease to take most any *nix source code download &
untar it; type ./configure; type make; type make install and be
done w/o
having to re-write the code
providing me the ease of use to move code that I am working on from
*nix to
Win* and back.
etc, etc
how do you define native code?
The cygwin dll( c code compiled on windows to run on windows) is as
native as any of the mingw .dll/.a files. And they (the mingw files)
are 3rd party libs.
reid
P.D. van Zelst wrote:
> But your application will be dependent on the Cygwin DLLs, which can be a
> nuisance. I always prefer native code over emulation, especially when the
> emulation requires 3rd party libraries.
>
> ________________________________
>
> From: dev...@li...
> [mailto:dev...@li...] On Behalf Of Reid
> Thompson
> Sent: Wednesday, October 29, 2003 11:00 PM
> To: Alain Paschoud; dev...@li...
> Subject: RE: [Dev-C++] Get socket with socket function
>
>
> If you configure Dev-C++ to use cygwin as the build env you will not
> have to
> change your code.
>
>
>
> reid
>
> -----Original Message-----
> From: Alain Paschoud [mailto:ala...@ge...]
> Sent: Wednesday, October 29, 2003 3:16 PM
> To: dev...@li...
> Subject: [Dev-C++] Get socket with socket function
>
>
>
> Hi all,
>
>
> I managed to compile a simple program that should just wait
> for an
> icoming connection on a inet type socket. I did it under Mac OS X and
> Linux,
> and I want to do the same thing with dev-cpp.
>
>
> Due to explanation give on this mailing list (thanks for your
> quick
> and usefull answers), I change the code to use winsock.h instead of
> sys/socket.h. I added the necessary library and DLLs. The program starts
> correctly and get it the function to create the socket file descriptor
> (it
> is very simple) :
>
>
> int sockfd;
>
>
> sockfd = socket(AF_INET, SOCK_STREAM, 0);
>
>
> BUT the result of socket function is always -1 (sockfd = -1).
> What
> could be the cause of that ? I found a similar example of socket creation
> for windows, I did exactly the same as in the example. The only thing
> I have
> found in "socket" man page is :
>
>
> "A -1 is returned if an error occurs"
>
>
> But how can an error happen at this step ?
>
>
> Thank you for any advice.
>
>
> Best regards.
>
>
>
|