[Dev-C++] Get socket with socket function
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Alain P. <ala...@ge...> - 2003-10-29 20:15:25
|
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. |