compiling socket client and server on cygwin

Discussion in 'C++' started by Eugene A, May 26, 2004.

  1. Eugene A

    Eugene A Guest

    Hello.


    I am trying to compile a linux socket server and a client in cygwin on
    windows. The g++ version is 3.3.1. The source was obtained from this
    location:

    http://www.linuxgazette.com/issue74/tougher.html

    ServerSoccket.cpp apparently compiles OK. Socket.cpp has a problem. Here's
    my output:

    $ make -f Makefile.txt
    g++ -c -o ServerSocket.o ServerSocket.cpp
    g++ -c -o Socket.o Socket.cpp
    Socket.cpp: In member function `int Socket::recv(std::string&) const':
    Socket.cpp:135: error: `cout' undeclared in namespace `std'
    Socket.cpp: In member function `bool Socket::connect(std::basic_string<char,
    std::char_traits<char>, std::allocator<char> >, int)':
    Socket.cpp:158: error: `inet_pton' undeclared (first use this function)
    Socket.cpp:158: error: (Each undeclared identifier is reported only once for
    each function it appears in.)
    make: *** [Socket.o] Error 1

    How can cout be undeclared in C++? Isnt that one of the basic basics?

    Please help,

    Eugene.
     
    Eugene A, May 26, 2004
    #1
    1. Advertising

  2. "Eugene A" <> wrote in message
    news:...
    > Hello.
    >
    >
    > I am trying to compile a linux socket server and a client in cygwin on
    > windows. The g++ version is 3.3.1. The source was obtained from this
    > location:
    >
    > http://www.linuxgazette.com/issue74/tougher.html
    >
    > ServerSoccket.cpp apparently compiles OK. Socket.cpp has a problem. Here's
    > my output:
    >
    > $ make -f Makefile.txt
    > g++ -c -o ServerSocket.o ServerSocket.cpp
    > g++ -c -o Socket.o Socket.cpp
    > Socket.cpp: In member function `int Socket::recv(std::string&) const':
    > Socket.cpp:135: error: `cout' undeclared in namespace `std'
    > Socket.cpp: In member function `bool

    Socket::connect(std::basic_string<char,
    > std::char_traits<char>, std::allocator<char> >, int)':
    > Socket.cpp:158: error: `inet_pton' undeclared (first use this function)
    > Socket.cpp:158: error: (Each undeclared identifier is reported only once

    for
    > each function it appears in.)
    > make: *** [Socket.o] Error 1
    >
    > How can cout be undeclared in C++? Isn't that one of the basic basics?
    >
    > Please help,
    >


    Look at the code, the author has failed to include <iostream> which is the
    header file that defined std::cout. Include <iostream> in Socket.cpp and you
    should be OK.

    john
     
    John Harrison, May 26, 2004
    #2
    1. Advertising

  3. Eugene A

    Jorge Rivera Guest

    [OT] Re: compiling socket client and server on cygwin

    Eugene A wrote:
    > Hello.
    >
    >
    > I am trying to compile a linux socket server and a client in cygwin on
    > windows. The g++ version is 3.3.1. The source was obtained from this
    > location:


    I think you might be doing unnecessary work. I ported a small library
    of code that uses Linux sockets to Windows sockets with minimal
    modifications (A few #ifdef's....).

    Is the rest of your project dependent on Unix standards?

    JLR
     
    Jorge Rivera, May 27, 2004
    #3
  4. Eugene A

    Eugene A Guest

    "John Harrison" <> wrote in message
    news:...
    >
    > > Socket.cpp: In member function `bool

    > Socket::connect(std::basic_string<char,
    > > std::char_traits<char>, std::allocator<char> >, int)':
    > > Socket.cpp:158: error: `inet_pton' undeclared (first use this function)
    > > Socket.cpp:158: error: (Each undeclared identifier is reported only once

    > for
    > > each function it appears in.)
    > > make: *** [Socket.o] Error 1
    > >
    > > How can cout be undeclared in C++? Isn't that one of the basic basics?
    > >
    > > Please help,
    > >

    >
    > Look at the code, the author has failed to include <iostream> which is the
    > header file that defined std::cout. Include <iostream> in Socket.cpp and

    you
    > should be OK.
    >
    > john
    >
    >


    Thanks. That did work. Weird I did not see it myself. But I still have the
    second error left. I do not know what inet_pton is. I know it is some kind
    of function, but that's about it.

    Eugene.
     
    Eugene A, May 27, 2004
    #4
  5. Eugene A

    Eugene A Guest

    Re: [OT] Re: compiling socket client and server on cygwin

    "Jorge Rivera" <> wrote in message
    news:Ou9tc.262450$...
    >
    > I think you might be doing unnecessary work. I ported a small library
    > of code that uses Linux sockets to Windows sockets with minimal
    > modifications (A few #ifdef's....).
    >
    > Is the rest of your project dependent on Unix standards?
    >
    > JLR


    It is not really a project. I have not touched C++ in quite a while. I
    thought if I could get this to work it could be a good experience.

    Eugene.
     
    Eugene A, May 27, 2004
    #5
  6. [OT] Re: compiling socket client and server on cygwin

    "Eugene A" <> wrote in message
    news:...
    >
    > "John Harrison" <> wrote in message
    > news:...
    > >
    > > > Socket.cpp: In member function `bool

    > > Socket::connect(std::basic_string<char,
    > > > std::char_traits<char>, std::allocator<char> >, int)':
    > > > Socket.cpp:158: error: `inet_pton' undeclared (first use this

    function)
    > > > Socket.cpp:158: error: (Each undeclared identifier is reported only

    once
    > > for
    > > > each function it appears in.)
    > > > make: *** [Socket.o] Error 1
    > > >
    > > > How can cout be undeclared in C++? Isn't that one of the basic basics?
    > > >
    > > > Please help,
    > > >

    > >
    > > Look at the code, the author has failed to include <iostream> which is

    the
    > > header file that defined std::cout. Include <iostream> in Socket.cpp and

    > you
    > > should be OK.
    > >
    > > john
    > >
    > >

    >
    > Thanks. That did work. Weird I did not see it myself. But I still have the
    > second error left. I do not know what inet_pton is. I know it is some kind
    > of function, but that's about it.
    >
    > Eugene.
    >


    I guess, but it's not a standard function so its off topic in this group.

    Quick google search turned up the following

    http://www.cygwin.com/ml/cygwin/2002-04/msg00043.html

    inet_pton is not supported in Cygwin as of April 2002.

    Better take this to the experts I think.

    john
     
    John Harrison, May 27, 2004
    #6
  7. Eugene A

    Eugene A Guest

    Re: [OT] Re: compiling socket client and server on cygwin

    "John Harrison" <> wrote in message
    news:...
    >
    > I guess, but it's not a standard function so its off topic in this group.
    >
    > Quick google search turned up the following
    >
    > http://www.cygwin.com/ml/cygwin/2002-04/msg00043.html
    >
    > inet_pton is not supported in Cygwin as of April 2002.
    >
    > Better take this to the experts I think.
    >
    > john
    >
    >


    Hmmmm.... That means back to square one. John, is there a place where I can
    find any other example of C++ socket programming. It does not have to be
    cygwin specific - something that compiles, works, and the code that I can
    dissect.

    Thanks,

    Eugene.
     
    Eugene A, May 27, 2004
    #7
  8. Re: [OT] Re: compiling socket client and server on cygwin

    Eugene A wrote:
    >
    > "John Harrison" <> wrote in message
    > news:...
    > >
    > > I guess, but it's not a standard function so its off topic in this group.
    > >
    > > Quick google search turned up the following
    > >
    > > http://www.cygwin.com/ml/cygwin/2002-04/msg00043.html
    > >
    > > inet_pton is not supported in Cygwin as of April 2002.
    > >
    > > Better take this to the experts I think.
    > >
    > > john
    > >
    > >

    >
    > Hmmmm.... That means back to square one. John, is there a place where I can
    > find any other example of C++ socket programming. It does not have to be
    > cygwin specific - something that compiles, works, and the code that I can
    > dissect.
    >


    For your inet_pton problem.

    A quick google search turned up the following link
    http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/net/Attic/inet_pton.c

    which seems to hold an implementation of that function.
    I have not looked through the function if it uses some
    other system dependent function.

    --
    Karl Heinz Buchegger
     
    Karl Heinz Buchegger, May 27, 2004
    #8
  9. Eugene A

    Default User Guest

    Re: [OT] Re: compiling socket client and server on cygwin

    Eugene A wrote:

    > Hmmmm.... That means back to square one. John, is there a place where I can
    > find any other example of C++ socket programming. It does not have to be
    > cygwin specific - something that compiles, works, and the code that I can
    > dissect.



    You need to find a resource specific to your implementation. Cygwin has
    a number of mailing lists, you should investigate them.




    Brian Rodenborn
     
    Default User, May 27, 2004
    #9
  10. Eugene A

    Alex Vinokur Guest

    Re: [OT] Re: compiling socket client and server on cygwin

    "Eugene A" <> wrote in message news:...
    [snip]
    > John, is there a place where I can
    > find any other example of C++ socket programming. It does not have to be
    > cygwin specific - something that compiles, works, and the code that I can
    > dissect.

    [snip]

    C++ stream-compatible TCP/IP sockets can be seen at http://alexvn.freeservers.com/s1/sock.html.
    The project has been compiled with GNU g++ version 3.3.1 (cygming special):
    $ g++ *.cpp -o sock_cyg.exe // CYGWIN
    $ g++ -mno-cygwin *.cpp -o sock_mgw.exe // MINGW

    --
    Alex Vinokur
    http://mathforum.org/library/view/10978.html
    http://sourceforge.net/users/alexvn
     
    Alex Vinokur, Jul 12, 2004
    #10
  11. Re: [OT] Re: compiling socket client and server on cygwin

    On Mon, 12 Jul 2004, Alex Vinokur wrote:

    > C++ stream-compatible TCP/IP sockets can be seen at http://alexvn.freeservers.com/s1/sock.html.


    No, I get an "404 Error -- File Not Found" error. Is itomewhere else?

    Regards,
    Peter Jansson
    http://jansson.net/
     
    Peter Jansson, Jul 13, 2004
    #11
  12. Eugene A

    AlesD Guest

    AlesD, Jul 13, 2004
    #12
  13. Eugene A

    Alex Vinokur Guest

    Re: [OT] Re: compiling socket client and server on cygwin

    "AlesD" <> wrote in message news:...
    > Peter Jansson wrote:
    > > On Mon, 12 Jul 2004, Alex Vinokur wrote:
    > >
    > >> C++ stream-compatible TCP/IP sockets can be seen at
    > >> http://alexvn.freeservers.com/s1/sock.html.


    I hope now it works.

    > >
    > >
    > > No, I get an "404 Error -- File Not Found" error. Is itomewhere else?
    > >
    > > Regards,
    > > Peter Jansson
    > > http://jansson.net/

    >
    > Try this one:
    >
    > http://sourceforge.net/projects/cpp-sockets/


    Yes, this is one of two download sites for C++ stream-compatible TCP/IP sockets:
    http://sourceforge.net/projects/cpp-sockets
    http://alexvn.freeservers.com/s1/zip_dir//sock.zip (via http://alexvn.freeservers.com/s1/sock.html only).


    --
    Alex Vinokur
    http://mathforum.org/library/view/10978.html
    http://sourceforge.net/users/alexvn
     
    Alex Vinokur, Jul 14, 2004
    #13
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    465
  2. Replies:
    0
    Views:
    435
  3. WELCOME to

    , Sep 3, 2003, in forum: Python
    Replies:
    1
    Views:
    516
    Robin Becker
    Sep 5, 2003
  4. Replies:
    0
    Views:
    416
  5. Replies:
    0
    Views:
    334
Loading...

Share This Page