By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,778 Members | 1,957 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,778 IT Pros & Developers. It's quick & easy.

compiling socket client and server on cygwin

P: n/a
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.
Jul 22 '05 #1
Share this Question
Share on Google+
12 Replies


P: n/a

"Eugene A" <lo*****@mailandnews.com> wrote in message
news:5a******************************@news.teranew s.com...
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
Jul 22 '05 #2

P: n/a
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
Jul 22 '05 #3

P: n/a

"John Harrison" <jo*************@hotmail.com> wrote in message
news:2h************@uni-berlin.de...
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.
Jul 22 '05 #4

P: n/a

"Jorge Rivera" <jo*****@rochester.rr.com> wrote in message
news:Ou*******************@twister.nyroc.rr.com...

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.
Jul 22 '05 #5

P: n/a

"Eugene A" <lo*****@mailandnews.com> wrote in message
news:fe******************************@news.teranew s.com...

"John Harrison" <jo*************@hotmail.com> wrote in message
news:2h************@uni-berlin.de...
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
Jul 22 '05 #6

P: n/a
"John Harrison" <jo*************@hotmail.com> wrote in message
news:2h************@uni-berlin.de...

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.
Jul 22 '05 #7

P: n/a
Eugene A wrote:

"John Harrison" <jo*************@hotmail.com> wrote in message
news:2h************@uni-berlin.de...

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/...ic/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
kb******@gascad.at
Jul 22 '05 #8

P: n/a
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
Jul 22 '05 #9

P: n/a

"Eugene A" <lo*****@mailandnews.com> wrote in message news:f9******************************@news.teranew s.com...
[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


Jul 22 '05 #10

P: n/a
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/

Jul 22 '05 #11

P: n/a
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.

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/
Jul 22 '05 #12

P: n/a

"AlesD" <al****@seznam.cz> wrote in message news:40**************@seznam.cz...
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


Jul 22 '05 #13

This discussion thread is closed

Replies have been disabled for this discussion.