Unidentified flying function
Results 1 to 6 of 6

Thread: Unidentified flying function

  1. #1

    Unidentified flying function

    ok here is the deal, Im reading winsock tutorials for C development, but the sample code I am trying to compile is missing the #include directive to tell the preprocessor to include the nessisary header file.

    The function establish() has not been declared:

    implicit declaration of function `int establish(...)'

    I have google searched to my hearts content, I cant find anything that tells me what header file has the establish function.

    dose someone know what header I need to #include?
    test

  2. #2
    Jaded Network Admin nebulus200's Avatar
    Join Date
    Jun 2002
    Posts
    1,356
    It might be helpful if you included the OS/compiler (haven't done anything in C in a while, but it was my experience that different compilers sometimes used different libraries/includes) that you are using. If we are talking windows, have you tried looking through the helpfiles ? If we are talking unix, have you tried /usr/include ?

    I looked through /usr/include/sys (where socket.h is) and found the function:
    socket.h:extern int connect(int, const struct sockaddr *, socklen_t);
    Might be in a different location depending on what OS, look for your socket.h header file...


    Nebulus
    There is only one constant, one universal, it is the only real truth: causality. Action. Reaction. Cause and effect...There is no escape from it, we are forever slaves to it. Our only hope, our only peace is to understand it, to understand the 'why'. 'Why' is what separates us from them, you from me. 'Why' is the only real social power, without it you are powerless.

    (Merovingian - Matrix Reloaded)

  3. #3
    The OS I am useing is Windows 98 SE, and the compiler I am useing is Dev-C++

    In windows since windows uses winsock to implement sockets I would use winsock.h instead of socket.h, but with that included I get the error. The problem is that the tutorial I am reading is giveing breif exampls as they go, I am copying their examples and puting it into a source file. I know that I need to include the wsock32.lib when I compile, which I have done in project options.

    When they are writeing the examples they are asumeing I know what basic header files I need to include, I know some but not all.

    Maybe this information might help..

    Posibly they were writing it in linux to be compatable with windows clients, not so sure.

    I did check the help file for my compiler but they dont seem to document functions. I checked Microsoft development network with no luck, I could always go and install borland again and use the help from there, but installing it for the sole purpose of geting the help file, and not to use it for development would be a waste of time.

    Is there a help file I can download anywhere?
    test

  4. #4
    Senior Member SodaMoca5's Avatar
    Join Date
    Mar 2002
    Posts
    236

    Help I Hope

    I went and did a little googling myself.

    I am not sure if this link holds the answer but it does have a snippet of code with all of the includes shown and uses the establish() function.

    http://www.cs.huji.ac.il/support/doc...ection3.2.html

    I hope this helps you out. I check the includes though and could not discover the function in any of them. As you pointed out this is using the socket.h not the wsock. Since I have done little of this (learnig perl to try the same type of thing) I cannot help out more except to try searching if this does not help.

    Sincerely,
    SodaMoca5
    \"We are pressing through the sphincter of assholiness\"

  5. #5
    Jaded Network Admin nebulus200's Avatar
    Join Date
    Jun 2002
    Posts
    1,356
    I haven't tried to do socket programming in windows, I frankly have tried to avoid it And with that being said, i would normally not volunteer what I am going to show, since I am not 100% sure it is correct, but since nobody has answered the question here goes.

    I have gone around looking at some code samples I found through google.

    The sample I am referencing can be found here

    It is actually kind of interesting because it considers both winsock and normal unix sockets

    That is what the #ifndef WIN32 before choosing either socket.h or winsock.h is all about...

    Which leads me to believe, that winsock.h should have that function declared...

    Looking at : Winsock 1.0

    (It completely describes winsock 1.0) and connect() is listed. I would suspect that you probably either are not using the library right or you aren't including the file right. Make sure your compiler knows where the include is and make sure it is including the library right.





    #define HAVE_BIND /* XXX -- for now, see below... */
    #define HAVE_HELP /* undefine if you dont want the help text */
    /* #define ANAL /* if you want case-sensitive DNS matching */

    #ifdef HAVE_STDLIB_H
    #include <stdlib.h>
    #else
    #include <malloc.h> /* xxx: or does it live in sys/ ?? */ #endif

    /* have to do this *before* including types.h. xxx: Linux still has it wrong */

    #ifdef FD_SETSIZE /* should be in types.h, butcha never know. */
    #undef FD_SETSIZE /* if we ever need more than 16 active */
    #endif /* fd's, something is horribly wrong! */
    #ifdef WIN32
    #define FD_SETSIZE 64 /* WIN32 does this as an array not a bitfield and it likes 64 */
    #else
    #define FD_SETSIZE 16 /* <-- this'll give us a long anyways, wtf */
    #endif
    #include <sys/types.h> /* *now* do it. Sigh, this is broken */

    #ifdef WIN32
    #undef HAVE_RANDOM
    #undef IP_OPTIONS
    #undef SO_REUSEPORT
    #include <windows.h>
    #endif

    #ifdef WIN32
    //#include "getopt.h"

    #define sleep _sleep
    #define strcasecmp strcmpi
    #define EADDRINUSE WSAEADDRINUSE
    #define ETIMEDOUT WSAETIMEDOUT

    #define ECONNREFUSED WSAECONNREFUSED #endif

    #ifdef HAVE_RANDOM
    #define SRAND srandom
    #define RAND random
    #else
    #define SRAND srand
    #define RAND rand
    #endif /* HAVE_RANDOM */

    #ifndef WIN32

    #include <sys/socket.h> /* basics, SO_ and AF_ defs, sockaddr, ... */
    #include <netinet/in.h> /* sockaddr_in, htons, in_addr */
    #include <netinet/in_systm.h> /* misc crud that netinet/ip.h references */
    #include <netinet/ip.h> /* IPOPT_LSRR, header stuff */
    #include <netdb.h> /* hostent, gethostby*, getservby* */
    #include <arpa/inet.h> /* inet_ntoa */

    #else
    #include <fcntl.h>
    #include <io.h>
    #include <conio.h>
    #include <winsock.h>
    #endif

    #include <stdio.h>
    #include <string.h> /* strcpy, strchr, yadda yadda */ #include <errno.h>
    #include <signal.h>

    void ores_init(void);



    neb
    There is only one constant, one universal, it is the only real truth: causality. Action. Reaction. Cause and effect...There is no escape from it, we are forever slaves to it. Our only hope, our only peace is to understand it, to understand the 'why'. 'Why' is what separates us from them, you from me. 'Why' is the only real social power, without it you are powerless.

    (Merovingian - Matrix Reloaded)

  6. #6
    A big thank you to both SodaMoca5 and nebulus200, I will now post a short tutorial in the tutorial section discusing the difernces between sockets in Windows and sockets in *nix.
    test

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •