Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > compiling socket client and server on cygwin

Reply
Thread Tools

compiling socket client and server on cygwin

 
 
Eugene A
Guest
Posts: n/a
 
      05-26-2004
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.


 
Reply With Quote
 
 
 
 
John Harrison
Guest
Posts: n/a
 
      05-26-2004

"Eugene A" <> wrote in message
news: 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


 
Reply With Quote
 
 
 
 
Jorge Rivera
Guest
Posts: n/a
 
      05-26-2004
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
 
Reply With Quote
 
Eugene A
Guest
Posts: n/a
 
      05-27-2004

"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.


 
Reply With Quote
 
Eugene A
Guest
Posts: n/a
 
      05-27-2004

"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.


 
Reply With Quote
 
John Harrison
Guest
Posts: n/a
 
      05-27-2004

"Eugene A" <> wrote in message
news: s.com...
>
> "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


 
Reply With Quote
 
Eugene A
Guest
Posts: n/a
 
      05-27-2004
"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.


 
Reply With Quote
 
Karl Heinz Buchegger
Guest
Posts: n/a
 
      05-27-2004
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/...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

 
Reply With Quote
 
Default User
Guest
Posts: n/a
 
      05-27-2004
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
 
Reply With Quote
 
Alex Vinokur
Guest
Posts: n/a
 
      07-12-2004

"Eugene A" <> wrote in message news: 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




 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Socket Support When Compiling Python 2.3.5 On Cygwin tom@tompurl.com Python 0 08-25-2005 03:39 PM
confirm unsubscribe from cygwin@cygwin.com cygwin-help@cygwin.com Python 0 09-05-2003 04:42 PM
WELCOME to cygwin@cygwin.com cygwin-help@cygwin.com Python 1 09-05-2003 07:46 AM
confirm unsubscribe from cygwin-announce@cygwin.com cygwin-announce-help@cygwin.com Python 0 09-05-2003 01:29 AM
confirm unsubscribe from cygwin@cygwin.com cygwin-help@cygwin.com Python 0 09-04-2003 06:34 PM



Advertisments