compiling socket client and server on cygwin

E

Eugene 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.
 
J

John Harrison

Eugene A said:
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
 
J

Jorge Rivera

Eugene said:
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
 
E

Eugene A

John Harrison said:
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.
 
E

Eugene A

Jorge Rivera said:
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.
 
J

John Harrison

Eugene A said:
John Harrison said:
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
 
E

Eugene A

John Harrison said:
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.
 
K

Karl Heinz Buchegger

Eugene said:
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.
 
D

Default User

Eugene said:
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
 
A

Alex Vinokur

Eugene A said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top